Home > database >  Mysql statement optimization
Mysql statement optimization

Time:03-02

Now with mysql query statement, the records of every time when the query, but takes longer, is there any bosses can simplify the query,
Need to query two tables, and the structure of the two tables are exactly the same, so here made a splicing,
The statement is as follows:

 select jobNumber,The Date, 
Area,
CellNo,
The shift,
The Name,
OriginalArea,
OriginalCell,
AccQty,
TransferDetail,
ClassesID,
AdjusDown,
AdjueCard
The from (select ` job_number ` as jobNumber,
The Date,
Area,
Cell_no as cellNo,
The shift,
The Name,
Original_Area as originalArea,
Original_Cell as originalCell,
ACC_Qty as accQty,
Transfer_Detail as transferDetail,
` Classes ID ` as classesID,
` ` work as adjusDown Adjus - unity,
` Adjus - card ` as adjueCard
The from accendance_all
Where ID not in (select ID from accendance_all where the Date & lt; 'the 2021-03-01 10:00:00 and Shift=' night ')
And ID not in (select ID from accendance_all where the Date & gt; 'the 2021-03-01 23:00:00' and Shift='day')
And the date between '2021-03-01 06:00:00' and 'the 2021-3-02 10:00:00')
The union
(select ` job_number ` as jobNumber,
The Date,
Area,
Cell_no as cellNo,
The shift,
The Name,
Original_Area as originalArea,
Original_Cell as originalCell,
ACC_Qty as accQty,
Transfer_Detail as transferDetail,
` Classes ID ` as classesID,
` ` work as adjusDown Adjus - unity,
` Adjus - card ` as adjueCard
The from accendance_list
Where ID not in (select ID from accendance_list where the Date & lt; 'the 2021-03-01 10:00:00 and Shift=' night ')
And ID not in (select ID from accendance_list where the Date & gt; 'the 2021-03-01 23:00:00' and Shift='day')
And the date between '2021-03-01 06:00:00' and '2021-3-02 s 10:00:00')) a
The order by a. obNumber, a. d. ate asc.

CodePudding user response:

Would it be convenient for you to want to realize what function said it to me? I know that you have completed but you see I see halo is not convenient to calculate
  • Related