mySQL 错误:#1248 - 每个派生表都必须有自己的别名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10495373/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
mySQL error: #1248 - Every derived table must have its own alias
提问by acctman
How would I correct this error by setting an alias? error: #1248 - Every derived table must have its own alias
如何通过设置别名来纠正此错误?错误:#1248 - 每个派生表都必须有自己的别名
SELECT
entry_id,
author_id,
title,
status
FROM exp_channel_titles
LEFT JOIN
(SELECT
entry_id,
field_id_14,
field_id_15,
field_id_25,
field_id_27,
field_id_28,
field_id_29,
field_id_30,
field_id_31,
field_id_32,
field_id_33,
field_id_34,
field_id_35
FROM exp_channel_data
WHERE entry_id = exp_channel_titles.entry_id)
LEFT JOIN
(SELECT
member_id,
email
FROM exp_members
WHERE member_id = exp_channel_titles.author_id)
WHERE title LIKE %Member%
AND status = 'complete'
回答by Nanne
Well, as the error says, you have to name every derived table. For instance
好吧,正如错误所说,您必须命名每个派生表。例如
(SELECT
member_id,
email
FROM exp_members
WHERE member_id = exp_channel_titles.author_id)
Is a derived table. Add a name like so:
是派生表。添加一个名称,如下所示:
(SELECT
member_id,
email
FROM exp_members
WHERE member_id = exp_channel_titles.author_id) tempTableNameGoesHere
(I think I'm sure there is no need for an as
between the bracket and the name, but I suppose you can try it, or look it up from here ;) )
(我想我确定as
括号和名称之间不需要,但我想您可以尝试一下,或者从这里查找;))
Your follow-up question (how long are we going to do this? :) )
你的后续问题(我们要做多久?:))
WHERE title LIKE %Member%
should be
应该
WHERE title LIKE '%Member%'
回答by Imdad
SELECT
ect.entry_id,
ect.author_id,
ect.title,
ect.status
FROM exp_channel_titles as ect
LEFT JOIN
(SELECT
entry_id,
field_id_14,
field_id_15,
field_id_25,
field_id_27,
field_id_28,
field_id_29,
field_id_30,
field_id_31,
field_id_32,
field_id_33,
field_id_34,
field_id_35
FROM exp_channel_data) as ecd
ON ecd.entry_id = ect.entry_id
LEFT JOIN
(SELECT
member_id,
email
FROM exp_members) as exm
ON exm.member_id = ect.author_id
WHERE ect.title LIKE '%Member%'
AND ect.status = 'complete'