OSEC

Neohapsis is currently accepting applications for employment. For more information, please visit our website www.neohapsis.com or email hr@neohapsis.com
Re: JOIN giving duplicate records

From: Halász Sándor (hsvtbbs.net)
Date: Tue Apr 03 2012 - 20:20:00 CDT


;>>> 2012/04/03 18:18 +0100, Tompkins Neil >>>>
Before sending the table definition, and queries etc, can anyone advise why
my query with four INNER JOIN might be give me back duplicate results e.g

100,UK,12121
100,UK,12121

Basically the query the statement AND
(hotel_facilities.hotelfacilitytype_id = 47 OR
hotel_facilities.hotelfacilitytype_id = 7) and if I add additional IDs
like AND (hotel_facilities.hotelfacilitytype_id = 47 OR
hotel_facilities.hotelfacilitytype_id = 7 OR
hotel_facilities.hotelfacilitytype_id = 8), it would return three records
like below when I'm expecting one record.

100,UK,12121
100,UK,12121
100,UK,12121

However in my SELECT statement if I use SELECT DISTINCT (field_name), I
only get back one record.
<<<<<<<<
It is in JOIN s nature to multiply output, but unless you show your whole query, noöne can comment on it. As for DISTINCT, its purpose is as you saw, to eliminate duplicates. Sometimes it is the best means for it--but you show too little for comment.

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe: http://lists.mysql.com/mysql