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 |
|
asm
Posting Yak Master
140 Posts |
Posted - 2007-02-19 : 07:39:32
|
| HiI have two table One- Product Two- ProductRateI want to retrive the data from both table.But the both table have different columns--I am using two query to get the result but wanted do this in single queryquery one-Select PL.PriceListNo, PL.Productcode, PL.PriceRate, PM.Description from productRate PL inner Join Product PM On PL.Productcode = PM.ProductCode query two-Select Productcode, Description from product where productcode not in (select productcode from productrate) thanks asm |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-02-19 : 07:41:40
|
| Select PL.PriceListNo, PL.Productcode, PL.PriceRate, PM.Description from productRate PL inner Join Product PM On PL.Productcode = PM.ProductCode UNION ALLSelect null, pm.Productcode, null, pm.Description from product pm left join productrate pl on PL.Productcode = PM.ProductCode where pl.productrate is nullPeter LarssonHelsingborg, Sweden |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2007-02-19 : 07:59:15
|
why not left join ?select p.ProductCode, p.Description, r.PriceListNo, r.PriceRatefrom product p left join productrate r on p.ProductCode = r.ProductCode KH |
 |
|
|
|
|
|
|
|