概述:
CODE:
SELECT * FROM
(SELECT * FROM
(SELECT *
FROM exp_channel_data
LEFT JOIN exp_channel_titles
ON exp_channel_data.entry_id = exp_channel_titles.entry_id
WHERE field_id_13 > '1'
ORDER BY field_id_13
ASC LIMIT 6
) AS tableStore)
AS tableStore
ORDER BY field_id_13 DESC
错误: - "重复列名称' entry_id'"
问题: - 我如何修复上面的代码,以便错误不会发生?
答案 0 :(得分:1)
我将废除所有无关的嵌套,而是将其简单地写为:
SELECT * FROM (
SELECT ecd.entry_id,
ecd.field_id_13,
ecd.field_id_11,
ect.title
FROM exp_channel_data ecd
LEFT JOIN exp_channel_titles ect
ON ecd.entry_id = ect.entry_id
WHERE ecd.field_id_13 > '1'
ORDER BY ecd.field_id_13 ASC
LIMIT 6
)
ORDER BY field_id_13 desc;
答案 1 :(得分:0)
问题是重复列说明其中一个select语句需要更多定义。
SELECT * FROM
(SELECT * FROM
(SELECT exp_channel_data.entry_id, exp_channel_data.field_id_13, exp_channel_data.field_id_11, exp_channel_titles.title
FROM exp_channel_data
LEFT JOIN exp_channel_titles
ON exp_channel_data.entry_id = exp_channel_titles.entry_id
WHERE field_id_13 > '1'
ORDER BY field_id_13
ASC LIMIT 6
) AS tableStore)
AS tableStore ORDER BY field_id_13 DESC