|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
Hello,
I have this problem. I wrote an app in ASP and SQL Server and ended having to use mySQL because that's all that's available on the remote server. The thing is, I had some queries written that simply won't work in mySQL and I can't find what is wrong with them. They worked perfectly in SQL Server and they aren't even complex. Then, mySQL is not running any subqueries even in the simplest SELECT * from A where x IN (SELECT x from B) form. It tells me there's an error 1064: "You have an error in your SQL syntax". What am I doing wrong? My original query was: select distinct clients.client_id, client_name, mat_name, end_date, budget_id, materials.mat_id from materials, matsteps, clients where materials.mat_id=matsteps.mat_id and materials.client_id=clients.client_id and step_id not in (select step_id from matsteps where prop_enddate is null) and (prop_enddate>=getdate() or getdate()-prop_enddate<=7) order by end_date I replaced getdate() by CURDATE() but the real problem is the subquery because if I delete that row, the query works. Any help will be appreciated. |
|
#2
|
||||
|
||||
|
What version of mysql? I don't believe subselects are implemented until version 4. For dates, I usually use NOW(), incidentally.
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#3
|
|||
|
|||
|
It's the latest version, I just downloaded it two days ago and got the production version 4.0.18 for Windows... The CURDATE() function works perfectly.
|
|
#4
|
|||
|
|||
|
You need 4.1.1
Last I checked, you needed mysql 4.1.1a-alpha, at least, to use subqueries.
Though it is alpha, it has been rock solid for my purposes so you might want to try before you pass judgement. |
![]() |
| Viewing: Dev Articles Community Forums > Databases > MySQL Development > Subqueries in mySQL |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|