clause is ambiguous

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

clause is ambiguous

Post by psurrena »

For the following query

Code: Select all

...connect to db

$a_id = $_GET['a_id'];
			
$query   = "SELECT * FROM article INNER JOIN image ON (image.a_id=article.a_id) WHERE a_id='$a_id'";
	
...rest of code
I get the error: "Column: 'a_id' in where clause is ambiguous"

What is this saying?
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

use WHERE image.a_id
mysql doesn't analyze the query in such depth to realize image.a_id=article.a_id makes it irrelevante which a_id to use in the WHERE clause.
User avatar
psurrena
Forum Contributor
Posts: 355
Joined: Thu Nov 10, 2005 12:31 pm
Location: Broolyn, NY

Post by psurrena »

Great, Thanks!
Post Reply