Help with nested sql-query

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
tores
Forum Contributor
Posts: 120
Joined: Fri Jun 18, 2004 3:04 am

Help with nested sql-query

Post by tores »

Hi

This nested query gives me a syntax error:
SELECT starttime, duration FROM mos_poly_activities WHERE actID = (SELECT lastactivity FROM mos_poly_lines WHERE linename = 'nettlinje');

But if I run the same two queries independently with the outer query using the result from the inner one, everything is ok.
The final result is an empty set, but that shouldn't effect the nested query I think.

Anyone know how to fix this error?

Regards tores
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

Database software? and version?

Mac
tores
Forum Contributor
Posts: 120
Joined: Fri Jun 18, 2004 3:04 am

Post by tores »

Sorry. Forgot to include it in the last post.

I'm using mysql 4.0.20a-debug
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

That's the issue then, subqueries are only supported from MySQL 4.1:
http://dev.mysql.com/doc/mysql/en/Subqueries.html

Mac
Post Reply