469,167 Members | 1,154 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,167 developers. It's quick & easy.

Does MySQL (4.0.20-standard) allow subqueries???

Im moving a development app (MySQL 5.0) to a different server which
runs MySQL 4.0.20-standard. I am getting errors on queries that have
subqueries such as...

SELECT id
FROM table1
WHERE id IN (
SELECT id FROM table1
)

Seems like such a simple query but it wont run? Anybody know the
answer and what other limitations im going to experience going from
version 5.0 down to 4.0.20-standard. -Nick
Jul 20 '05 #1
5 2174
Nick wrote:
Im moving a development app (MySQL 5.0) to a different server which
runs MySQL 4.0.20-standard. I am getting errors on queries that have
subqueries such as...

SELECT id
FROM table1
WHERE id IN (
SELECT id FROM table1
)

Seems like such a simple query but it wont run? Anybody know the
answer and what other limitations im going to experience going from
version 5.0 down to 4.0.20-standard. -Nick


Subqueries are not supported in 4.0.x but will be in 4.1.x

The manual's always a good start for finding out what is and is not
available in MySQL.

This page has a feature list of what's in 4.0.x
http://dev.mysql.com/doc/mysql/en/Nu..._features.html

This page has a feature list of what's in 4.1.x
http://dev.mysql.com/doc/mysql/en/Nu..._features.html

This one has planned features for 5.0
http://dev.mysql.com/doc/mysql/en/TODO_MySQL_5.0.html

By reading each of those and comparing, you'll be able to see what the
difference between them is.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 20 '05 #2
Nick wrote:
Seems like such a simple query but it wont run? Anybody know the
answer and what other limitations im going to experience going from
version 5.0 down to 4.0.20-standard. -Nick


Subqueries are not supported in version 4.0.x of MySQL.
MySQL 4.1 introduced support for subqueries.

See:
http://dev.mysql.com/doc/mysql/en/AN...ubqueries.html

And here's a page to help rewriting some types of subqueries as joins:
http://dev.mysql.com/doc/mysql/en/Re...ubqueries.html

There are many, many changes between 4.0 and 5.0. I cannot guess what
features you are using that were introduced after 4.0.

Try starting here: "C. MySQL Change History"
http://dev.mysql.com/doc/mysql/en/News.html

Regards,
Bill K.
Jul 20 '05 #3
There is a paper on mysql explaining the work around for subqueries.
SELECT id
FROM table1
WHERE id IN (
SELECT id FROM table1
)

this for example, even in mysql 5.0 I would run as

Select a.id
From table1 a, table1 b
Where a.id = b.id
Jul 20 '05 #4
Great...... Anyone know of a good webhost that offers MySQL 4.1+ or
Postgres??? This is going to add alot of time to the project.

-Nick
Jul 20 '05 #5
Nick wrote:
Great...... Anyone know of a good webhost that offers MySQL 4.1+ or
Postgres??? This is going to add alot of time to the project.


There is unlikely to be any who have MySQL 4.1 yet because it's still in
beta. And there certainly won't be any hosts with 5.0 because that's alpha
software. If your main problem is subqueries you can often rewrite them
using joins, or use code to create the in() part of the clause (a little
slow, I know). Otherwise, there are plenty of hosts with Postgres - do a
Google search on --> hosting postgres <-- and look at all the sponsored
links.

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 20 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Dan Anderson | last post: by
reply views Thread by laurie | last post: by
2 posts views Thread by David Nettles | last post: by
2 posts views Thread by c-bass | last post: by
reply views Thread by Andrew Crook | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.