Может ли кто-нибудь объяснить два вопроса ниже относительно структуры и синтаксиса?Множественная структура выбора в mysql
1: Почему первый блок будет в порядке, а второй имеет ошибку 1060 для двойного имени столбца FD_ID? Как я могу это исправить?
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' псевдонимы, и проблема, скорее всего, уйдет –
Просто попытался это, но это не сработало. Спасибо, хотя :) –