0
次の2つのSQL文を1つに結合して合計23行(最初のsqlは23行、2行目は20行が20行あります。 sql)の最初のsqlと2番目のsqlのh3dac値が列に表示されます。2つのSQL文を垂直方向に結合する
いずれか回避してください。
$sql_u1="select * from (select location1.location as locs, location1.elevation as elvn,location1.group as groups, shiftdata.location as loc1, shiftdata.date, shiftdata.shift, shiftdata.h3dac as h3dac1 from location1 inner join shiftdata on location1.location=shiftdata.location where shiftdata.unit= 1 ORDER BY shiftdata.date desc, shiftdata.shift desc, location1.loc_id limit 23) as a left JOIN (select location as loc1, date as date2, shift as shift2, h3dac as h3dac2 from shiftdata where unit= 1 ORDER BY date desc, shift desc limit 23 offset 23) as b on a.locs=b.loc1 left join (select location as loc3, date as date3, shift as shift3, h3dac as h3dac3 from shiftdata where unit= 1 ORDER BY date desc, shift desc limit 23 offset 46) as c on a.locs=c.loc3";
$sql_u2="select * from (select location2.location as locs,location2.elevation as elvn, location2.group as groups, shiftdata.location as loc1, shiftdata.date, shiftdata.shift, shiftdata.h3dac as h3dac1 from location2 inner join shiftdata on location2.location=shiftdata.location where shiftdata.unit= 2 ORDER BY shiftdata.date desc, shiftdata.shift desc, location2.loc_id limit 20) as a left JOIN (select location as loc1, date as date2, shift as shift2, h3dac as h3dac2 from shiftdata where unit= 2 ORDER BY date desc, shift desc limit 20 offset 20) as b on a.locs=b.loc1 left join (select location as loc3, date as date3, shift as shift3, h3dac as h3dac3 from shiftdata where unit= 2 ORDER BY date desc, shift desc limit 20 offset 40) as c on a.locs=c.loc3";
は、$ sql_u1の末尾にスペースがないので、 "UNION"にする必要があります。 –
これを修正しました。ありがとう。 –