Re: INNER JOIN

From: Date: Thu, 23 Nov 2000 01:41:07 +0000
Subject: Re: INNER JOIN
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-26748@lists.php.net to get a copy of this message
yes to all 3 ----- Original Message ----- From: "Ignacio Vazquez-Abrams" <ignacio@openservices.net> To: "Jeremy" <sparhawk@cleanweb.net> Cc: <php-general@lists.php.net> Sent: Wednesday, November 22, 2000 2:28 PM Subject: Re: [PHP] INNER JOIN > On Wed, 22 Nov 2000, Jeremy wrote: > > > The query does not fail, but instead returns a blank screen. > > I cannot change all other ratings to comments.rating... as rating = the avg > > of those comments.rating for a specific tabid > > > > A tab would be synonymous with an Article > > ----- Original Message ----- > > From: "Ignacio Vazquez-Abrams" <ignacio@openservices.net> > > To: "Jeremy" <sparhawk@cleanweb.net> > > Cc: <php-general@lists.php.net> > > Sent: Wednesday, November 22, 2000 2:14 PM > > Subject: Re: [PHP] INNER JOIN > > > > > > > On Wed, 22 Nov 2000, Jeremy wrote: > > > > > > > Is this proper syntax for MySQL? > > > > > > > > For some reason, it is not returning results > > > > > > > > if (!($result = mysql_query("SELECT comments.tabid, avg(comments.rating) > > as rating, tabs.band, > > > > tabs.song FROM comments, tabs WHERE comments.tabid = tabs.id AND rating > > <> 'none' AND tabs.instrument = '$instrument' > > > > GROUP BY comments.tabid > > > > ORDER BY rating DESC > > > > "))) { > > > > echo("Fail"); > > > > } > > > > > > > > > > Some quick questions: > > > 1) Does the query work when entered interactively? > > > 2) Does it work if you precede 'rating' by 'comments.' in all > > > places > > (except > > > after 'as', of course)? > > > > > > -- > > > Ignacio Vazquez-Abrams <ignacio@openservices.net> > > > > > > > Hmm... avg() and "<>'none'" together? Check that again. > > Okay, let's work through the query one bit at a time. > > 1) Are you using the database first? (Just checking.) > 2) Does '$instrument' contain anything. > 3) Do any records at all satisfy the WHERE criteria with any of the possible > values for '$instrument'? > > -- > Ignacio Vazquez-Abrams <ignacio@openservices.net> > >

« previous php.general (#26748) next »