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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Help in a Query !

Author  Topic 

sqlilliterate
Starting Member

40 Posts

Posted - 2009-07-28 : 14:41:22
Hello... Please help me forming a select query which returns my desired output...

Table 1

id name
----------- -----
1 Name1
1 Name11
2 Name2
2 Name21
4 Name4
Table 2

id Div
----------- -----
1 div1
1 div12
1 div13
2 div2
3 div3
My expected output is...

id name Div
----------- ------- -----
1 Name1 div1
1 Name12 div12
1 NULL div13
2 Name2 div2
2 Name22 NULL
3 NULL div3
4 Name4 NULL

Your suggestions would immensely help me.

Thanks

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-07-28 : 14:47:28
Your sample data shows the possibility to compare the end of the name with the end of the Div.
But I fear that this possibility isn't given by the real data - right?


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

- Advertisement -