最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
where clause is ambiguous
时间:2010-01-23 编辑:简简单单 来源:一聚教程网
在一次使用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'
-
下一个: sql 多表查询
相关文章
- where,group by,having,limit的出现顺序 02-25
- MySQL登录、访问及退出操作解析 10-18
- sql语句 update字段null不能用is null问题解析 09-28
- SQL Server ISNULL 不生效原因及解决分析 09-28
- 关于if exists的用法及说明分析 09-28
- Access数据库日常维护方法 09-28