Forum Moderators: open

Message Too Old, No Replies

Sum query mystery.

         

mcs services

2:08 am on Feb 2, 2008 (gmt 0)

10+ Year Member



What am I missing?

 mysql_query("UPDATE customers SET balance = (SELECT SUM(b.balance) FROM trailers AS b WHERE b.customer_id = customers.customer_id)")or die(mysql_error());

The query worked locally using WAMP...but when I upload to providers server...it gives a syntax error:
"You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT SUM(b.balance) FROM trailers AS b WHERE b.customer_id ="

MySQL 4.0.16 running on both. What did I miss?

Thanks for any help!
Chris

mcs services

3:25 am on Feb 2, 2008 (gmt 0)

10+ Year Member



I figured it out...

4.0 versions and prior to this do not support subqueries (as I just found out after several hours of attempting subqueries).

4.1 and newer support subqueries.

Hope this helps someone.

coopster

11:14 pm on Feb 7, 2008 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Ouch!

Welcome to WebmasterWorld, mcs services.

Yes, you nailed it.