Thanks for the help. Got that to work no problem.
Mike ----- Original Message ----- From: "Harrison C. Fisk" <[EMAIL PROTECTED]> To: "Mike" <[EMAIL PROTECTED]> Cc: "mysql list" <[EMAIL PROTECTED]> Sent: Thursday, June 13, 2002 5:48 PM Subject: Re: Need Help with JOIN > Mike, > > With the way you have it written below, all of the pic1_id, pic2_id, > pic3_id, and pic4_id must be equal (because they all equal pic.pic_id). > Since this wasn't true for any of the rows, that is why you were > getting no results. > To get each picture value seperately, you will have to do one join for > each pic#_id, which will give you something like: > > SELECT * > FROM pics AS p1, pics AS p2, pics AS p3, pics AS p4 , outings AS o > WHERE o.pic1_id=p1.pic_id > AND o.pic2_id=p2.pic_id > AND o.pic3_id=p3.pic_id > AND o.pic4_id=p4.pic_id; > > Or as you had it written before using INNER JOIN's: > > SELECT * > FROM outings as o INNER JOIN pics AS p1 ON o.pic1_id=p1.pic_id > INNER JOIN pics AS p2 ON o.pic2_id=p2.pic_id > INNER JOIN pics AS p3 ON o.pic3_id=p3.pic_id > INNER JOIN pics AS p4 ON o.pic4_id=p4.pic_id; > > Either of those should work fairly well. Hope that helps some. > > Harrison > > > Mike wrote: > > >Hello, > > > >I have 2 tables(pics and outings) > > > >pics > >pic_id, tinyint > >path, varchar > > > >outings > >outings_id, tinyint > >pic1_id, tinyint > >pic2_id, tinyint > >pic3_id, tinyint > >pic4_id, tinyint > > > >When i try to do a join like this > > > >mysql_query("SELECT * FROM pics inner join outings on > >outings.pic1_id=pic.pic_id and outings.pic2_id=pic.pic_id and > >outings.pic3_id=pic.pic_id",$db) or die(mysql_error()); > > > >Nothing is returned. The query runs ok(nothing from mysql_error). When I > >drop outings.pic2_id=pic.pic_id and outings.pic3_id=pic.pic_id from the > >query works and returns the path of the pic. > > > >I'm fairly certain that the above returns nothing because of the multiple > >pic.pic_id's in the query. But I don't know what to do get it > >working(Redesign? or Is there something I could change in the query?) > > > >Thanks in advance for any help, > >Mike > >sql,mysql > > > > > >--- > >Outgoing mail is certified Virus Free. > >Checked by AVG anti-virus system (http://www.grisoft.com). > >Version: 6.0.330 / Virus Database: 184 - Release Date: 2/28/02 > > > > > >--------------------------------------------------------------------- > >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 > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > 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 --- Outgoing mail is certified Virus Free. Checked by AVG anti-virus system (http://www.grisoft.com). Version: 6.0.330 / Virus Database: 184 - Release Date: 2/28/02 --------------------------------------------------------------------- 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