百分百源码网-让建站变得如此简单! 登录 注册 签到领金币!

主页 | 如何升级VIP | TAG标签

当前位置: 主页>网站教程>数据库> where clause is ambiguous
分享文章到:

where clause is ambiguous

发布时间:01/15 来源: 浏览: 关键词:
where clause is ambiguous


在一次使用mysql数据库查询的时候出现错误提示 Column 'languageid' in ,这个错误in 多半是因为多表查询的时候几个表中同时出现了某个相同的列名,而在查询条件WHERE后面又没有指定是那个表,而引起的
又或者是查询结果里面有两个相同的列名,而没有指定是哪个表
使用的时候可以这样,mysql查询前面加表名可避免出现错误Column 'languageid' in
SELECT tablea.id aid table.id bid WHERE tablea.id = tableb.id

SELECT *
FROM tbl_listings
WHERE postcode = 'var1' AND catID = 'var2' AND stateID = 'var3'
ORDER BY listingName ASC

using the following variables

name: var1
default value: -1
run-time value: $_GET['postcode']

name: var2
default value: -1
run-time value: $_GET['catID']

name: var3
default value: -1
run-time value: $_GET['stateID']


I, however, want to get the category name from the category table using a join so I tried this:

 


Code:
SELECT *
FROM tbl_listings LEFT JOIN tbl_category ON tbl_listings.catID = tbl_category.catID
WHERE postcode = 'var1' AND catID = 'var2' AND stateID = 'var3'
ORDER BY listingName ASCusing the following variables

name: var1
default value: -1
run-time value: $_GET['postcode']

name: var2
default value: -1
run-time value: $_GET['catID']

name: var3
default value: -1
run-time value: $_GET['stateID']

 

This gives me an error saying: Column: 'catID' in where clause in ambiguous.


WHERE postcode = 'var1' AND tbl_listings.catID = 'var2'

OR
PHP Code:
WHERE postcode = 'var1' AND tbl_category.catID = 'var2'

打赏

打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,你说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

百分百源码网 建议打赏1~10元,土豪随意,感谢您的阅读!

共有5人阅读,期待你的评论!发表评论
昵称: 网址: 验证码: 点击我更换图片
最新评论

本文标签

广告赞助

能出一分力是一分吧!

订阅获得更多模板

本文标签

广告赞助

订阅获得更多模板