MySQL Forums
Forum List  »  InnoDB

Nested select in MySQL 4.0.26?
Posted by: Simon Croome
Date: November 25, 2005 04:12AM

The query below works on MySQL 4.1.13 and 5.0.15, but not on 4.0.26 (which my provider is running). The error reported is:

"Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT p.nid as nid, count(p.nid) as days_avail, SUM(a.price) a"

SELECT COUNT( * ) FROM node n, (
SELECT p.nid AS nid, count( p.nid ) AS days_avail, SUM( a.price ) AS price
FROM ec_rental_availability a, ec_rental p
WHERE (
a.date >= '2005-12-22'
AND a.date < '2005-12-31'
)
AND a.status =1
AND a.nid = p.nid
GROUP BY p.nid
) AS ap
WHERE ap.days_avail = '9'
AND ap.nid = n.nid
LIMIT 0 , 30

Can anyone help me with a way to re-phrase the query so it works with the older version of MySQL? I'm relatively new to MySQL so don't know whether nested selects are even supported in this version or if there's a workaround.

Any help would be much appreciated!

Thanks,
Simon

Options: ReplyQuote


Subject
Views
Written By
Posted
Nested select in MySQL 4.0.26?
7707
November 25, 2005 04:12AM
3284
November 25, 2005 12:45PM
2470
November 25, 2005 03:31PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.