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.
Author |
Topic |
iNko
Starting Member
19 Posts |
Posted - 2013-01-22 : 10:17:16
|
Hey, i need help with a code that would take a values from 2 columns, and show only 1 result if theres more than 1..Table1ID-Name1-Name12-Name2Table2ID-Name1-Name15-Name5I want something like this:SELECT name FROM Table1 OR Table2 WHERE id='1'Also when it returns (Name1, Name1) result, i would want it to be just (Name1).Can someone help me with this? ty. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-01-22 : 10:57:33
|
[code]SELECT COALESCE(a.id,b.id) AS id, COALESCE(a.Name, b.Name) AS NAME FROM Table1 a FULL JOIN Table2 b ON a.id = b.id;[/code] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-01-23 : 01:00:35
|
[code]SELECT Name FROM Table1UNIONSELECT Name FROM Table2[/code]------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
|
|
|
|
|