Select problems
Posted: Thu Aug 03, 2006 11:20 am
I am running a big query where I do a bunch of left joins. It works fine but what I want is to be able to return rows ONLY if there is data in this one table that matches the main Id.
I have a user images table
and I am searching on what is there the 'fkListingId'. So basically when I run the search I only want a row to be returned if any only if there is a record for that Id in the listing_images table.
I tried LEFT JOIN but since there can be like 10 rows in the listing_images table for each listing then I would get each listing returned to me 10 times which is not gonna work as it has to just return each listing once.
I don't really know how to go about this so any help is appreciated
I have a user images table
Code: Select all
CREATE TABLE `listing_images` (
`Id` int(10) NOT NULL auto_increment,
`fkUserId` int(10) NOT NULL,
`fkListingId` int(10) NOT NULL,
`Path` varchar(255) NOT NULL,
`isThumb` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`Id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
I tried LEFT JOIN but since there can be like 10 rows in the listing_images table for each listing then I would get each listing returned to me 10 times which is not gonna work as it has to just return each listing once.
I don't really know how to go about this so any help is appreciated