List:General Discussion« Previous MessageNext Message »
From:Jim Faucette Date:May 18 1999 10:11pm
Subject:Re: Joining tables
View as plain text  
Dan Parisien wrote:
> 
> Why would I want to join my tables? how would I do it?
> will it save me from doing selects where i see if
> (table1.sID=table2.sID) ??

Adding to Tim's reply. In a normalized database you'd need joins. In a
contact list a person can have more than one phone number, so:

Table A:
num INT UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT;
lname CHAR(20) NOT NULL;
fname CHAR(20) NOT NULL;
KEY n (lname, fname);

Table B:
num INT UNSIGNED NOT NULL;
phone char(20);

Then to get all of John Smith's phone numbers you'd:
SELECT fname, lname, phone FROM A, B
WHERE lname ='Smith' AND fname='John' AND A.num = B.num;

  jim...
Thread
Joining tablesDan Parisien19 May
  • Re: Joining tablesThimble Smith19 May
  • Re: Joining tablesJim Faucette19 May
    • Re: Joining tablespeter19 May
      • Re: Joining tablesBenjamin Pflugmann21 May