Wednesday, March 7, 2012

Need a query

Table1(id,Name),Table2(myid,address)
if i apply query (Select * from Table1,Table2 where Table1.ID=Table2.myid) then if i have data table1(1,imran),table2(0,xyz) then result not show but i required result if equal or not equalYour query is using an implicit INNER JOIN. Try using an OUTER JOIN instead:

SELECT
T1.ID,
T1.Name,
T2.myid,
T1.address
FROM
Table1 T1
LEFT OUTER JOIN
Table2 T2 ON T1.ID = T2.myid

This will select ALL records from Table1 whether or not there is a match in Table2.

Terri

No comments:

Post a Comment