PDA

View Full Version : Working with 2 tables at once ?????


dawilis
07-21-2003, 04:59 AM
I have two tables
Contact
ID = autonumber
NameID = Id1 from Master_Roll tabel
ContactDate = contact Date
details = Deatails of this contact

Master_Roll
ID1 = Autonumber
Surname = Surname
First NAme = First Name
DOB
SEX
PHONE
ADDRESS
EMAIL

I want to query the contact Table and the Master_roll Details table, I also want to add and update both tables.
Which is the best way to do this?

raf
07-21-2003, 06:14 PM
Kind of broad questions.
To query --> use a join. Like

SELECT contact.*, Master_Roll.* FROM contact INNER JOIN Master_Roll ON contact.NameID = Master_Roll.ID1

About your other question : 2 option:
- control this inside your app --> using multiple querys
- let the db control it, by using "on update cascade"
http://www.mysql.com/doc/en/InnoDB_foreign_key_constraints.html

Bets way : depends on the sort of actions to perform.