php where 子句中的列不明确 - 这是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6062185/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 23:15:32  来源:igfitidea点击:

Column in where clause is ambiguous - What does that mean?

phpmysqljoinmysql-error-1052

提问by Ben

I've come across this error in MySQL for the join clause but I'm fairly new to the JOINargument and I'm not sure what this means. Can anyone help?

我在 MySQL 中遇到了 join 子句的这个错误,但我对这个JOIN论点还很陌生,我不确定这意味着什么。任何人都可以帮忙吗?

Column 'id' in where clause is ambiguous

where 子句中的列“id”不明确

SELECT * FROM (`venues`) 
JOIN `venues_meta` ON `venues_meta`.`venue_id` = `venues`.`id` 
WHERE `id` = '12'

回答by Chris Morgan

You need to fully qualify idbecause venuesand venues_metaboth have a column called id.

您需要完全限定id,因为venuesvenues_meta这两个有一个名为列id

回答by Scott C Wilson

I think you want:

我想你想要:

SELECT * FROM `venues` v, `venues_meta` m  where v.venue_id = m.id AND  m.id = '12'

(but be sure it's v.venue_id you want and not v.id)

(但请确保它是您想要的 v.venue_id 而不是 v.id)

回答by E.Prokhorov

Try this Code

试试这个代码

SELECT v.*
FROM `venues` AS `v` 
INNER JOIN `venues_meta` AS `vm` ON `vm`.`venue_id` = `v`.`id` 
WHERE `v`.`id` = '12'