Where clause is ambiguous

Source: Internet
Author: User

Where clause is ambiguous

Where clause is ambiguous
The error message "Column 'languageid' in where clause is ambiguous" appears during a query using the mysql database, this error in where clause is ambiguous is probably caused by the fact that a same column name appears in several tables during multi-Table query, and the table is not specified after the WHERE clause of the query condition.
Or there are two identical column names in the query results, but no table is specified.
In this way, you can avoid the error Column 'your ageid' in where clause is ambiguous by adding a table name before mysql query.
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'

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.