June 2008
Sun Mon Tue Wed Thu Fri Sat
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30          
Search

 
Catagories
Archives
Recent Entries
Links
RSS
ms access left outer join
Catagory: sql server · This Entry · Comment(0) · eMail entry · Google
June 24, 2004 04:52 PM

sql server

i'm not a big fan, but sometimes ms access makes for a decent tool. however, syntax for various sql operations are different. access can still perform a left outer join, here's how...



simple select query using an inner join :

(brackets are mostly optional, but you can't use table aliases, so you have to write them out!)

SELECT *
FROM table1
INNER JOIN table2 ON ([tabla1].[id]=[table2].[id])
AND ([table1].[col1]=[table2].[column1])

here's a left outer join ~ the syntax is just "LEFT JOIN"

SELECT *
FROM table1
LEFT JOIN table2 ON ([tabla1].[id]=[table2].[id])
AND ([table1].[col1]=[table2].[column1])



update query... again, can't use table aliases, so you have to write them out.

UPDATE table1 INNER JOIN table2
ON ([tabla1].[id]=[table2].[id])
AND ([table1].[col1]=[table2].[column1])
SET
[table1].[col1]=table2.column1



help docs aren't helpful. if you need to convert columns to numeric, or to text use: CInt, CLng, CStr et al.

SELECT *, CLng(table1.col1), CStr(table1.id)
FROM table1
where CLng(table1.col1) = 1





Comments

Post a comment
Name:


Email Address:


URL:


Comments: