By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,360 Members | 1,412 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,360 IT Pros & Developers. It's quick & easy.

identity table

P: 1
Hi

I have 2 tables like

Searchtable
-----------------
searchid name
----------- --------
s1 chandu
s2 sony
s3 kiran
s4 chandu
s5 babu

Master table(Data from search table avoiding duplicates)
-----------------
masterID SearchID Name
------------ ----------- ---------
M1 s1 chandu
M2 s2 sony
M3 s3 kiran
M4 s5 babu


I want a table to maintain Identity like this as output

identitytable
-----------------
masterID SearchID
------------ -------------
M1 s1
M2 s2
M3 s3
M1 s4
M4 s5

Can any one tell me how to write query for this solution

Thanks in advance.
Mar 26 '08 #1
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
Hi

I have 2 tables like

Searchtable
-----------------
searchid name
----------- --------
s1 chandu
s2 sony
s3 kiran
s4 chandu
s5 babu

Master table(Data from search table avoiding duplicates)
-----------------
masterID SearchID Name
------------ ----------- ---------
M1 s1 chandu
M2 s2 sony
M3 s3 kiran
M4 s5 babu


I want a table to maintain Identity like this as output

identitytable
-----------------
masterID SearchID
------------ -------------
M1 s1
M2 s2
M3 s3
M1 s4
M4 s5

Can any one tell me how to write query for this solution

Thanks in advance.
Names are not really a good column to use as key, but here's your query:
Expand|Select|Wrap|Line Numbers
  1. select MasterTable.MasterID   , Searchtable.searchid
  2. from Searchtable
  3. left join MasterTable on MasterTable.name = SearchTable.Name 
-- CK
Mar 26 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.