我一直在MySQL 5.5(Percona的)運行的網站,並使用此查詢,它的工作原理:問題使用子查詢的MySQL 5.5 VS 5.6
SELECT
bds.FromStationPositionID
FROM
BusDestinationSegments AS bds
LEFT JOIN BusDestinationSegmentPrices AS bdsp ON bds.SegmentID = bdsp.BusDestinationSegmentID
AND EXISTS (
SELECT
BusDestinationScheduleID
FROM
BusDestinationSchedule
WHERE
BusDestinationScheduleDate + INTERVAL bdssf.DayOfset DAY = '2016-01-26'
),
BusDestinationStations AS bdssf
我需要升級到5.6(再次Percona的),所以我剛剛(在開發服務器上)。 但是,此查詢現在不起作用。它告訴我:
[Err] 1054 - Unknown column 'bdssf.DayOfset' in 'where clause'
我應該補充一點,我已經檢查過,列在那裏。
我猜測有一些從5.5到5.6的變化,這不允許我在子查詢中使用列,但我找不到任何關於該主題的內容。
有沒有人有這方面的經驗或任何人都可以提出一種方法,我試圖完成將工作?
您是否嘗試過使用'BusDestinationStations.Dayofset'它是否正在工作? –
它工作在一個不同的查詢,但在這個查詢中使用它會意味着另一個表的實例,這不是我想要完成的。即便如此,它不與「BusDestinationStations」工作 - 它說未知列「BusDestinationStations.DayOfset」在「where子句」 – DreamWave
一旦我粘貼在MySQL它給了我一個SQL語法錯誤 '選擇 bds.FromStationPositionID FROM BusDestinationSegments AS bds LEFT JOIN BusDestinationSegmentPrices AS bdsp ON bds.SegmentID = bdsp。BusDestinationSegmentID 與EXISTS(SELECT BusDestinationScheduleID FROM BusDestinationSchedule WHERE BusDestinationScheduleDate + INTERVAL bdssf.DayOfset DAY = '2016年1月26日' )(BusDestinationStations AS bdssf)' –