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
 How to make a SQL Subquery

Author  Topic 

repstronics
Starting Member

4 Posts

Posted - 2009-11-07 : 12:47:21
Hi I have the following information on a table

Contact | Contsupref | Linkacct | Recid | State
Jhon Smith | Supplier | NULL | AI0IT33 | Mass
E-mail | John@smith.com| AI0IT33 | AIXIT34 | NULL

and I want to have a query that has the result of
John Smith John@smith.com

The only information I linking the tables is Recid and Linkacct

If you can Help I'll really appreciate it

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-11-07 : 13:01:55
Are there more linked records than this about email?
If not then you can do the following:

select t1.Contact,t2.Contsupref
from your_table as t1
join your_table as t2 on t2.Linkacct = t1.Recid



No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

repstronics
Starting Member

4 Posts

Posted - 2009-11-07 : 13:18:38
Sorry I forgot to mention that also the state has to be Mass
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-11-07 : 13:49:09
select t1.Contact,t2.Contsupref
from your_table as t1
join your_table as t2 on t2.Linkacct = t1.Recid
where t1.State='Mass'


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

repstronics
Starting Member

4 Posts

Posted - 2009-11-07 : 15:14:13
Vielen Dank!!!
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-11-07 : 15:25:03
Es war mir ein Vergnügen!


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -