我的sql语句有什么问题?

时间:2011-11-23 17:12:46

标签: sql left-join

我知道where子句是如何工作的,但在这种情况下,它似乎无法工作..可能是因为我对所有左连接和重命名以及你有什么感到困惑。

所以这个语句在没有where的情况下工作正常,但是当我添加where子句时,它说where子句中的列是未知的......有没有人知道什么是错的?

select t1.name AS DistroName,t2.name AS OriginName, t3.name AS DesktopName, t3.name AS desktoptest , t2.country, t1.status, t2.description , t5.name as oldtest, t6.name as multitest, t4.name as begintest
from alldistros t1 
LEFT join origin t2 on t1.name=t2.name
LEFT join desktop t3 on t2.name=t3.name
LEFT join beginnerdistributions t4 on t3.name=t4.name
LEFT join oldcomputers t5 on t4.name=t5.name
LEFT join multimedia t6 on t5.name=t6.name
WHERE DistroName = 'Absolute LInux'

谢谢 阮

3 个答案:

答案 0 :(得分:5)

尝试更改

WHERE DistroName = 'Absolute LInux'

WHERE t1.name = 'Absolute LInux'

答案 1 :(得分:0)

在where子句

中使用t1.name
select t1.name AS DistroName,t2.name AS OriginName, t3.name AS DesktopName, t3.name AS desktoptest , t2.country, t1.status, t2.description , t5.name as oldtest, t6.name as multitest, t4.name as begintest
from alldistros t1 
LEFT join origin t2 on t1.name=t2.name
LEFT join desktop t3 on t2.name=t3.name
LEFT join beginnerdistributions t4 on t3.name=t4.name
LEFT join oldcomputers t5 on t4.name=t5.name
LEFT join multimedia t6 on t5.name=t6.name
WHERE t1.name= 'Absolute LInux'

答案 2 :(得分:0)

对于多个表格,您可能有一个含糊不清的DistroName,请尝试where t1.DistroName = "" or t1.DistroName ...