Page 1 of 1

Using subqueries doesn`t work

Posted: Wed May 10, 2006 3:28 pm
by antubis
Hello again,

I`m trying to update a filed with an sum from other table. I`m using this query:

Code: Select all

UPDATE table1 SET table1field =
  (SELECT SUM(table2field) FROM table2 where table2field2 = 123) WHERE table1field = 123;
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(workers) FROM buildings where uid = 20023)' at line

Is it my mistake or my mysql version is very low and don`t support subqueries. Btw how can I understand it. Is there a query witch return mysql information ( equal to phpinfo() function in PHP )

Thank you all

Posted: Wed May 10, 2006 3:32 pm
by s.dot
I believe subquery support was added in 4.1 (could be wrong, but close)

Posted: Wed May 10, 2006 3:34 pm
by timvw

Posted: Thu May 11, 2006 4:05 am
by dibyendrah
scottayy wrote:I believe subquery support was added in 4.1 (could be wrong, but close)
That's right ! Only from MySQL 4.1, subquery support is added .

Posted: Thu May 11, 2006 5:37 am
by Weirdan
Btw how can I understand it. Is there a query witch return mysql information ( equal to phpinfo() function in PHP )

Code: Select all

select version();