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
 select data from mutliple tables.

Author  Topic 

Mahavirjadhav
Starting Member

18 Posts

Posted - 2010-07-09 : 00:07:26
Hi All,
I have following tables.

1. Shop
(shopID ,Address, city, state, shopType )
2. ShopOffers
(shopID, Offerdetails, From_dt, To_dt)

I want write query
when shop has offer then it should return details of shop and offerdtails. otherwise if it is not having any offer then it should return only details of shop only.
Thank you.

Mahavir

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-07-09 : 00:23:08
Are you looking for this:

Select S.Address, S.City,S.State, S.Shoptype , SO.OfferDetails as OfferDetail
From Shop S left join ShopOffers SO on S.ShopID = SO.ShopId

In case your requirement is different then please post some sample data and expected output.

Regards,
Bohra

I am here to learn from Masters and help new bees in learning.
Go to Top of Page
   

- Advertisement -