Home > database >  According to the time column mysql query is a different column
According to the time column mysql query is a different column

Time:10-11

Database format:

Want to query result:


In case the when can I do, but the results will be three lines, have a line can be generated

CodePudding user response:

Try left the join

CodePudding user response:

 select 
At1. As A '2019 A'
At1. B as' 2019 B ',
At1. C as' 2019 C,
At2. As A '2018 A'
At2. B as' 2018 B ',
At2. C as' 2018 C,
At3. As A '2017 A'
At3. B as' 2017 B ',
At3. C as' 2017 C,
At4. As A '2016 A'
At4. B as' 2016 B ',
At4. C as a '2016 C'
From the at the as at1
Left the join at the as at2 on at1. Datetime & lt;> At2. Datetime
Left the join at the as at3 on at2. Datetime & lt;> At3. Datetime
Left the join at the as at4 on at3. Datetime & lt;> At4. Datetime
Where at1) Datetime=2019 and at2) Datetime=2018 and at3 Datetime=2017 and at4. Datetime=2016


CodePudding user response:

Understand, thank you for your brother
  • Related