任何人都可以請解釋下面關於結構和語法的兩個問題嗎?mysql中的多選結構
1:爲什麼第一個塊沒問題,但是第二個塊對於重複的列名FD_ID有錯誤1060?我該如何解決它?
SELECT * from(
(SELECT a.FD_ID as id, aa,bb from
(select FD_ID, NT_VALUE as aa from nutrition_amount where nutrition_amount.NT_ID = 203) as a left join
(SELECT FD_ID, NT_VALUE as bb from nutrition_amount where nutrition_amount.NT_ID = 204) as b on a.FD_ID = b.FD_ID) as ab left join
(SELECT FD_ID, NT_VALUE as cc from nutrition_amount WHERE nutrition_amount. NT_ID = 205) AS c on ab. id = c. FD_ID)
SELECT distinct * from(
(select * from
(select FD_ID, NT_VALUE as aa from nutrition_amount where nutrition_amount.NT_ID = 203) as a left join
(select FD_ID, NT_VALUE as bb from nutrition_amount where nutrition_amount.NT_ID = 204) as b on a.FD_ID = b.FD_ID) as ab left join
(SELECT FD_ID, NT_VALUE as cc from nutrition_amount WHERE nutrition_amount. NT_ID = 205) AS c on ab. id = c. FD_ID)
2:我試圖建立多個結構到10個不同的FD_ID。這種結構是否可用來做到這一點?見解,請:) /任何更好的解決方案來處理這類問題?
SELECT * FROM (
SELECT * from(
SELECT * FROM (
SELECT * FROM (
SELECT * from(
SELECT * FROM (
SELECT * FROM (
SELECT * from(
(select a.FD_ID as id, aa,bb from
(select FD_ID, NT_VALUE as aa from nutrition_amount where nutrition_amount.NT_ID = 203) as a left join
(select FD_ID, NT_VALUE as bb from nutrition_amount where nutrition_amount.NT_ID = 204) as b on a.FD_ID = b.FD_ID) as ab left join
(SELECT FD_ID, NT_VALUE as cc from nutrition_amount WHERE nutrition_amount. NT_ID = 205) AS c on ab. id = c. FD_ID) AS bc left join
(SELECT FD_ID, NT_VALUE as dd from nutrition_amount WHERE nutrition_amount. NT_ID = 208) AS d on bc. id = d. FD_ID) AS cd left join
(SELECT FD_ID, NT_VALUE as ee from nutrition_amount WHERE nutrition_amount. NT_ID = 269) AS e on cd. id = e. FD_ID) AS de left join
(SELECT FD_ID, NT_VALUE as ff from nutrition_amount WHERE nutrition_amount. NT_ID = 291) AS f on de. id = f. FD_ID) AS ef left join
(SELECT FD_ID, NT_VALUE as gg from nutrition_amount WHERE nutrition_amount. NT_ID = 303) AS g on ef. id = g. FD_ID) AS fg left join
(SELECT FD_ID, NT_VALUE as hh from nutrition_amount WHERE nutrition_amount. NT_ID = 307) AS h on fg. id = h. FD_ID) AS hi left join
(SELECT FD_ID, NT_VALUE as ii from nutrition_amount WHERE nutrition_amount. NT_ID = 605) AS i on hi. id = i. FD_ID) AS ij left join
(SELECT FD_ID, NT_VALUE as jj from nutrition_amount WHERE nutrition_amount. NT_ID = 606) AS j on ij. id = j. FD_ID)
給定的錯誤是從1064線7
感謝您的幫助:)
給出所有這些:'FD_ID'別名,問題可能會消失 –
剛剛嘗試過,但沒有奏效。謝謝,雖然:) –