Groups | Blog | Home
all groups > sql server programming > october 2005 >

sql server programming : Help with SQL query


Tim Harvey
10/27/2005 11:19:57 PM
Please bare with me in trying to get my point across, I'm new to SQL and
would appreciate the help so much.

I have two table Table1 and Table2. There is a one to many relationship
between Table1 and Table2. Table2 has a list of widgets, I need to create a
query that would show the records from Table1 along with it's related
records and all non related records from Table2. So if I have 5 widgets and
only two have related records in Table1 results should be

Table1ID(2) fkTable2 Table2(widgetname1)
Table1ID(2) fkTable2 Table2(widgetname2)
null null Table2(widgetname3)
null null Table2(widgetname4)
null null Table2(widgetname5)

When I filter the query on another Table1ID, I would need the same sort of
result for each Table1ID.




R.D
10/28/2005 2:06:04 AM
try this
SELECT TABLE1.COL1,TABLE1.COL2,TABLE2.COL1,TABLE2.COL2 FROM TABLE1 RIGHT
OUTER JOIN TABLE2 ON TABLE1.COL1 = TABLE2.COL1
--
Regards
R.D
--Knowledge gets doubled when shared


[quoted text, click to view]
AddThis Social Bookmark Button