Question Locked

Distinct qurery

0 helpful
4 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

Hi every one,
How can use DISTINCT even when I use joined table and the selected field contain text and image fields

in other word how can I get distinct value from this query:
SELECT SiteHotel.HotelID, SiteHotel.Logo, SiteHotel.HotelName, SiteHotel.Stars, SiteHotel.Theme, SiteHotel.City, SiteHotel.Location FROM SiteHotel INNER JOIN Room ON SiteHotel.HotelID = Room.HotelID INNER JOIN Reserve ON Room.[Room No] = Reserve.[Room No] WHERE (my condition)

I tried to use:
SELECT distinct SiteHotel.HotelID, SiteHotel.Logo, SiteHotel.HotelName, SiteHotel.Stars, SiteHotel.Theme, SiteHotel.City, SiteHotel.Location FROM SiteHotel INNER JOIN Room ON SiteHotel.HotelID = Room.HotelID INNER JOIN Reserve ON Room.[Room No] = Reserve.[Room No] WHERE (my condition)
but it dosn't work

4 replies

by tony hopkinson

If you could do distinct on a blob, you wouldn't, it would be a binary compare for every record and would be hideously expensive.

Try this

Select innerq.*,SiteHotel.Logo
From SiteHotel,(
SELECT distinct SiteHotel.HotelID, SiteHotel.HotelName, SiteHotel.Stars, SiteHotel.Theme, SiteHotel.City, SiteHotel.Location FROM SiteHotel INNER JOIN Room ON SiteHotel.HotelID = Room.HotelID INNER JOIN Reserve ON Room.[Room No] = Reserve.[Room No] WHERE (my condition)) innerq
Where innerq.HotelId = SiteHotel.HotelID

ie get everything but the blob in the inner query and then join and get the blob.

innerq can be anyunique name it's just an alias for the inner query.

HtHs

This discussion is closed to new replies.