RE: [PHP] syntax error on mysql select statement

2002-10-13 Thread John W. Holmes

ORDER BY and LIMIT go at the end...after WHERE.

---John Holmes...

 -Original Message-
 From: Pablo Oliva [mailto:[EMAIL PROTECTED]]
 Sent: Sunday, October 13, 2002 12:13 AM
 To: [EMAIL PROTECTED]
 Subject: [PHP] syntax error on mysql select statement
 
 Can anyone see any problems with the following:
 SELECT * FROM ad AS t1, ad_location AS t2 ORDER BY t1.ad_ts_update
LIMIT
 0,40 WHERE t1.ad_location = t2.ad_loc_id AND ( (t1.ad_cdl_a = on OR
 t1.ad_cdl_b = on) AND t1.ad_longhaul = on AND t1.ad_fulltime = on )
AND
 ( t2.ca_losangeles = 1 OR t2.ca_santaana = 1 ) AND t1.ad_display = 1
 
 The error I get is:
 You have an error in your SQL syntax near 'WHERE t1.ad_location =
 t2.ad_loc_id AND ( t1.ad_cdl_a = on AND t1.ad_longhaul = ' at line 1
 
 
 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] syntax error on mysql select statement

2002-10-13 Thread Pablo Oliva

Can anyone see any problems with the following:
SELECT * FROM ad AS t1, ad_location AS t2 ORDER BY t1.ad_ts_update LIMIT
0,40 WHERE t1.ad_location = t2.ad_loc_id AND ( (t1.ad_cdl_a = on OR
t1.ad_cdl_b = on) AND t1.ad_longhaul = on AND t1.ad_fulltime = on ) AND
( t2.ca_losangeles = 1 OR t2.ca_santaana = 1 ) AND t1.ad_display = 1

The error I get is:
You have an error in your SQL syntax near 'WHERE t1.ad_location =
t2.ad_loc_id AND ( t1.ad_cdl_a = on AND t1.ad_longhaul = ' at line 1 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] syntax error on mysql select statement

2002-10-13 Thread Marco Tabini

Yes, the LIMIT clause must be at the end of the line. Take a look at the
documentation:

http://www.mysql.com/doc/en/SELECT.html


On Sun, 2002-10-13 at 00:12, Pablo Oliva wrote:
 Can anyone see any problems with the following:
 SELECT * FROM ad AS t1, ad_location AS t2 ORDER BY t1.ad_ts_update LIMIT
 0,40 WHERE t1.ad_location = t2.ad_loc_id AND ( (t1.ad_cdl_a = on OR
 t1.ad_cdl_b = on) AND t1.ad_longhaul = on AND t1.ad_fulltime = on ) AND
 ( t2.ca_losangeles = 1 OR t2.ca_santaana = 1 ) AND t1.ad_display = 1
 
 The error I get is:
 You have an error in your SQL syntax near 'WHERE t1.ad_location =
 t2.ad_loc_id AND ( t1.ad_cdl_a = on AND t1.ad_longhaul = ' at line 1 
 
 
 -- 
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php