Re: Problem with composed queries (eg UNION, INTERSECT ..) and PHP

From: Date: Tue, 09 Jan 2001 13:30:42 +0000
Subject: Re: Problem with composed queries (eg UNION, INTERSECT ..) and PHP
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-5745@lists.php.net to get a copy of this message
Hello Stas, My mistake !!! I finally found the day after the post why it wasn't working : that was a syntax problem. My query was in fact: $query = "SELECT DE_LI, DE_ID,DE_NO"; $query.=" FROM DEs "; $query.="WHERE DE_TP = 40 ORDER BY DE_NO"; $query.=" MINUS"; $query.=" SELECT DE_LI, DE_ID,DE_NO"; $query.=" FROM DEs "; $query.=" WHERE DE_TP = 38 ORDER BY DE_NO"; And I stupidly forgot that the ORDER BY shouldn't stand twice. And I was strongly conviced that it was a problem with the ';' because when testing the query with SQL+ I wasn't using the ordering, and each SQL statement have to be ended by a ';'. I was a mile away thinking it was that, and the parser is a little bit laconic by just saying that the statement is not well ended. Anyway, thanks for tkaing the time to answer, and sorry for missing to post my own answer to my own problem :-) Stas Trefilov wrote:
Hello, Olivier Bourgeois! You wrote:
SELECT field1, field2 FROM table1 WHERE (some conditions) UNION SELECT field1, field2 FROM table1 WHERE (some conditions)
The syntax is correct. Your code snippet?


« previous php.db (#5745) next »