Re: need confirmation on a SELECT statement

From: Date: Fri, 08 Sep 2000 09:02:56 +0000
Subject: Re: need confirmation on a SELECT statement
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-2735@lists.php.net to get a copy of this message
Hi Arne. I'm no expert but I think the sql syntax says you should group by all the non-calculated fields. So the statment $sql .= "GROUP BY p.id, p.name, p.price, b.sid, b.artno " is correct one according to the standarts. -- Meir Kriheli MKsoft computer systems "There's someone in my head but it's not me" - Pink Floyd > when I run the following SELECT statement on mysql > everything's fine ... it fails, however, in InterBase > telling me > > Warning: InterBase: Dynamic SQL Error SQL error > code = -104 invalid column reference in > /usr/local/apache/htdocs/projects/demoshopibase/showbasket.phtml on line 25 > > > The statement goes here: > > $sql = "SELECT p.id, p.name, p.price, b.sid, b.artno, count(b.artno) " > $sql .= "FROM products p, basket b " > $sql .= "WHERE (p.id = b.artno) AND (b.sid = '$sid') " > $sql .= "GROUP BY p.id, b.artno " > > > If I want to run it with InterBase, I need to add ALL columns to the GROUP > BY > clause. Although I am not SQL guru, that seems strange to me. > > This form works and need somebody to tell me if this is my lach of SQL or a > specialty > in PHP / InterBase interconnection ... (I couldn't believe that either, to > be honest) > > > $sql = "SELECT p.id, p.name, p.price, b.sid, b.artno, count(b.artno) " > $sql .= "FROM products p, basket b " > $sql .= "WHERE (p.id = b.artno) AND (b.sid = '$sid') " > $sql .= "GROUP BY p.id, p.name, p.price, b.sid, b.artno " > > > Does anyone have a clue or can at least direct me to find the clue myself? > Arne

« previous php.db (#2735) next »