* UPDATE *
Sorry! I was in a bit busy and in a hurry, so didnt clear this up properly.
Essentially the 3 queuries all relate to a users details. I am updating a site for a new client, where i am restricted by the current database structure. As such my aim is to try and get all this info in one db calll rather than 3 seperate ones, as this would appear to be the most efficient way of the two.
I was hoping someone smarter than me might know of some ninja moves that could retrieve this in one go. I really should have spent more time trying this myself before posting.
Thanks for your time.
The common value is @dealerId – which is an int value.
Thanks
SELECT TOP(100) PERCENT dbo.ReferenceItems.Title
FROM dbo.AdvertiserLanguageLink
INNER JOIN dbo.ReferenceItems
ON dbo.AdvertiserLanguageLink.LanguageId = dbo.ReferenceItems.Id
WHERE (dbo.AdvertiserLanguageLink.AdvertiserId = @dealerId)
ORDER BY dbo.ReferenceItems.Title
SELECT TOP (100) PERCENT dbo.AircraftTypes.AircraftTypeDescription, dbo.AircraftTypes.AircraftTypeId
FROM dbo.AdvertiserAircraftTypeLink
INNER JOIN dbo.AircraftTypes
ON dbo.AdvertiserAircraftTypeLink.AircraftTypeId = dbo.AircraftTypes.AircraftTypeId
WHERE (dbo.AdvertiserAircraftTypeLink.AdvertiserId = @dealerId)
ORDER BY dbo.AircraftTypes.SortSequence
SELECT TOP (1) dbo.Addresses.Country, dbo.Addresses.Telephone1
FROM dbo.AdvertiserAddressLink
INNER JOIN dbo.Addresses
ON dbo.AdvertiserAddressLink.AddressId = dbo.Addresses.Id
WHERE (dbo.AdvertiserAddressLink.AdvertiserId = @dealerId)
AND (dbo.Addresses.AddressType = 1 OR dbo.Addresses.AddressType = 0)
ORDER BY dbo.Addresses.Sequence
You can’t/shouldn’t combine them.
You are selecting very different data from different tables in all 3. It looks like they are completely unrelated. What would you expect the “combined” result set to look like? You are combining books, aircraft, and phone information?
What exactly is your goal? If you tell us that we can maybe give you a different (correct) path to it.