|
Posted by J.O. Aho on 02/09/07 15:03
Kenoli wrote:
> I get the error:
> MySQL Error: Column 'person_id' in where clause is ambiguous
This happens sometimes when you have tables with the same column names, you
have to specify which tables person_id you are going to use
In your case it would be tbl_person.person_id or tbl_contact_info.person_id
IMHO it's always good to specify a columns table when using joins, you get a
lot less of these errors that way and you easilly know from which table a
column is when you look at the query.
$query = "SELECT * FROM tbl_person JOIN tbl_contact_info USING
(person_id) WHERE person_id = '5' OR person_id = '6';";
would become:
$query = "SELECT * FROM tbl_person JOIN tbl_contact_info ON
(tbl_person.person_id=tbl_contact_info.person_id) WHERE tbl_person.person_id
= '5' OR tbl_person.person_id = '6'";
Yes, it will be a bit longer to type, but will work better.
--
//Aho
Navigation:
[Reply to this message]
|