I'm pretty sure that I have two queries that could be combined into one query using a JOIN, but I can not figure out how to do it. Basically, I need all the rows from TABLE1 that are either NOT in TABLE2 or IN TABLE2 BUT have been marked as voted by a user id. Yes, that makes no sense, I'll try to explain it in the layout of the tables and sql below.
Here's the table structure: hh_images id smallint unsigned not null auto_increment primary_key, fname varchar(20) not null default 'n/a', img varchar(64) not null default 'n/a' hh_votes vote tinyint unsigned not null default 0, vote_for smallint unsigned not null default 0, vote_by smallint unsigned not null default 0 hh_votes.vote_for and vote_by are indexed. hh_votes.vote_by contains a user id, once someone has voted for a particular image, their id, vote and which image they voted on are stored in hh_votes, this is so they can not vote on an image again. The two queries I have to get the images someone has NOT voted on are: SELECT vote_for FROM hh_votes WHERE vote_by=1; =>4 SELECT id,fname,img FROM hh_images WHERE id NOT IN(4); =>Results where id is not 4 I tried this query, but it only works if there is only one user id in hh_votes: SELECT hh_images.id,hh_images.fname,hh_images.img FROM hh_images LEFT JOIN hh_votes ON hh_images.id=hh_votes.vote_for WHERE hh_votes.vote_for IS NULL AND hh_votes.vote_by<>1; (I realize that is because of hh_votes.vote_by<>1 gives matching rows for other user id's in hh_images). Could someone give me some direction here? --------------------- Johnny Withers [EMAIL PROTECTED] p. 601.853.0211 c. 601.209.4985 --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php