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 |
trackjunkie
Starting Member
31 Posts |
Posted - 2010-07-08 : 13:59:33
|
I have a stored procedure that I want to take one parameter and select data from three different tables. I have three select statements which all work individually but I cannot join them correctly. I want the output to be a single row of data. "Union" does not seem to work because they return different numbers of values. My three select statements are:select(select Flex_VendorError.* From Flex_VendorErrorWhere Flex_VendorError.QA# = @QANum)select vendor.phonefrom vendorjoin Flex_VendorError on ltrim(vendor.vend_num)=ltrim(Flex_VendorError.Vendor) and ltrim(Flex_VendorError.QA#) = @QANumselect vendaddr.name,vendaddr.addr##1,vendaddr.addr##2,vendaddr.addr##3,vendaddr.city,vendaddr.state,vendaddr.fax_num,vendaddr.zip from vendaddrjoin Flex_VendorError on ltrim(vendaddr.vend_num)=ltrim(Flex_VendorError.Vendor) and ltrim(Flex_VendorError.QA#) = @QANum |
|
Bustaz Kool
Master Smack Fu Yak Hacker
1834 Posts |
Posted - 2010-07-08 : 18:39:22
|
If each select returns a single row, you can use a cross join.=======================================A couple of months in the laboratory can save a couple of hours in the library. -Frank H. Westheimer, chemistry professor (1912-2007) |
 |
|
slimt_slimt
Aged Yak Warrior
746 Posts |
Posted - 2010-07-08 : 23:24:32
|
can you be more specific which columns are you returning in select list and how do you want this data bo be joined in a single row - by summing up, counting, etc.? |
 |
|
trackjunkie
Starting Member
31 Posts |
Posted - 2010-07-09 : 08:29:16
|
I am just using this to feed a report so I do not need to combine the results in any way. Each select will return only one row with between 1 and many columns. Basically I just want to combine the results of the three selects into one long row. |
 |
|
|
|
|