Using subqueries doesn`t work

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
antubis
Forum Newbie
Posts: 16
Joined: Sun Apr 30, 2006 1:48 pm
Location: Pavlikeni, Bulgaria
Contact:

Using subqueries doesn`t work

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

I believe subquery support was added in 4.1 (could be wrong, but close)
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

User avatar
dibyendrah
Forum Contributor
Posts: 491
Joined: Wed Oct 19, 2005 5:14 am
Location: Nepal
Contact:

Post 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 .
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post 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();
Post Reply