Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL query

Author  Topic 

chxxangie
Starting Member

16 Posts

Posted - 2008-05-26 : 08:31:32
there are 2 tables: tbl_m, tbl_v.
column in tbl_m: m_vendorNo, m_itemNo
column in tbl_v: v_vendorNo, v_itemNo
both have the same columns.
some of the records in tbl_v might not exist in tbl_m, but the records in tbl_m sure will exist in tbl_v.
the result that i want to retrieve is:-
pre-condition: m_itemNo = v_itemNo, and then,
retrieve the v_vendorNo which exist in tbl_v, but not exist in tbl_m.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-26 : 08:37:33
select v.*
from tbl_v AS v
left join tbl_m AS m on m.m_vendorNo = v.v_vendorNo
and m.m_itemNo= v.v_itemNo
where m.m_vendorNo is null



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

chxxangie
Starting Member

16 Posts

Posted - 2008-05-26 : 09:10:24
sorry for i m stil new in SQL.
may i ask what i sthe meaning at the 1st line, select v.*
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-05-26 : 09:15:31
it returns all columns in the tbl_v table.


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

chxxangie
Starting Member

16 Posts

Posted - 2008-05-26 : 09:32:04
thank you for your patience to teach me.
Go to Top of Page
   

- Advertisement -