Reply to Re: Looping through 2 query results

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация