| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

02-18-04, 00:26
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 14
|
|
|
sql problem. Help please
|
|
SQL problem in mysql
INSERT INTO task (user_id, poster_id, project_id, mount_id, subject, time, finish, priority_id, type_id, status_id) VALUES (999, 999, 111, (select MAX(ID) from task where subject = 'Software', 'training', -1, -1, 2, 2, 1);
and
UPDATE task SET mount_id = 2
Where Id = select Max(ID) from task where subject ='Consulting';
they both gave me this 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 Max(ID) from task where subject ='Consulting'' at line 1
Please and Thank You
|
|

02-18-04, 08:00
|
|
Registered User
|
|
Join Date: Oct 2003
Location: Slovakia
Posts: 482
|
|
|
Re: sql problem. Help please
Quote:
Originally posted by Paingiver
SQL problem in mysql
INSERT INTO task (user_id, poster_id, project_id, mount_id, subject, time, finish, priority_id, type_id, status_id) VALUES (999, 999, 111, (select MAX(ID) from task where subject = 'Software', 'training', -1, -1, 2, 2, 1);
and
UPDATE task SET mount_id = 2
Where Id = select Max(ID) from task where subject ='Consulting';
they both gave me this 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 Max(ID) from task where subject ='Consulting'' at line 1
Please and Thank You
|
What version of MySQL you are using? Because subselects (nested queries) are supported only 4.1.x and newer version
|
|

02-18-04, 08:59
|
|
Registered User
|
|
Join Date: Feb 2004
Location: Erehwon
Posts: 18
|
|
|
|
Don't know about the second query, but you didn't close the parens around the subquery in your first one
[code]
INSERT INTO task (user_id, poster_id, project_id, mount_id, subject, time, finish, priority_id, type_id, status_id) VALUES (999, 999, 111, (select MAX(ID) from task where subject = 'Software'), 'training', -1, -1, 2, 2, 1);
[\code]
|
|

02-18-04, 09:25
|
|
SQL Consultant
|
|
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
|
|
PHP Code:
insert
into task
( user_id
, poster_id
, project_id
, mount_id
, subject
, time
, finish
, priority_id
, type_id
, status_id
)
select 999
, 999
, 111
, max(id)
, 'training'
, -1
, -1
, 2
, 2
, 1
from task
where subject = 'Software'
|
|

02-18-04, 18:28
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 14
|
|
MySql v 4.0.17, so i guess i should update my mysql. I'm downloading it now.
|
|

02-18-04, 18:48
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 14
|
|
To Ursus,
Yes i did close the statement.
Thank You
|
|

02-18-04, 20:46
|
|
Registered User
|
|
Join Date: Feb 2004
Posts: 14
|
|
After updating mysql to v 5.0.0a i now have this error:
You can't specify target table 'task' for update in FROM clause
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|