selecting from multiple tables on one database

From: Date: Sun, 22 Apr 2001 05:13:23 +0000
Subject: selecting from multiple tables on one database
Groups: php.db 
Request: Send a blank email to php-db+get-8778@lists.php.net to get a copy of this message
I have checked the mysql.com docs and phpbuilder.com and zend.com and I am more confused than ever on selecting a single common record from multiple tables. Here is what I have so far. MySQL 3.23.22 PHP 4.0.3pl1 RedHat 6.1 members table1 ID # auto_increment UserName # unique Name Address City State ZIP table2 ID # auto_increment independent of table1 UserName # unique Birthday Sex Age table3 ID # auto_increment independent of table1 and table2 UserName SpouseName SpouseBirthay SpouseAge DateTime # last update I am trying to pull out UserName, City, State from table1 - Sex, Age from table2 - and Age from table3 where the ID number of table1 is '1'; Meaning I only want one row containing the common information. If I use the following select statement I get 12 rows of data that do not contain what I am looking for! SELECT table1.UserName, table1.City, table1.State, table2.Sex, table2.Age, table3.SpouseAge FROM table1, table2, table3 WHERE table1.ID = '1' Can someone help please, or at least send me in the right direction? t.

« previous php.db (#8778) next »