For example you want two tables that have a column that has an identical id and that id you want to print out in another table. how will you code it?

Recommended Answers

All 4 Replies

Tonkz,

Oh boy, you're going to have fun. You're about to learn all about SQL joins. Look them up in the MS SQL manual (w3schools provides a reasonable primer).

In short, there's no unique answer to your question. It depends on which type of join is appropriate to your tables and the particular query you are trying to compose, which itself depends on the way in which your data is normaisled into tables and how the tables are keyed.

Have fun

Airshow

Oh I read about that, but it seems that I was doing it wrong my code doesn't work. Maybe I should have posted it. Well i'll post it tomorrow hopefull too sleepy to do it now =.= by the way, you're right it was fun!!!

SELECT TABLE1.*,TABLE2.* FROM TABLE1 INNER JOIN TABLE2
ON TABLE1.ID=TABLE2.ID

NOW EXAMINE THE RESULT. CHANGE INNER word by LEFT,RIGHT,FULLER..........

Inner Join (id is foreign key)

SELECT *
FROM table1 t1, table2 t2
WHERE t1.id = t2.id

Left Outer Join (id is foreign key)

SELECT *
FROM table1 t1, table2 t2
WHERE t1.id *= t2.id
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.