Page 2 of 2
Posted: Tue Aug 01, 2006 3:07 pm
by volka
The structure of the update statement is simply wrong.
You cannot combine different UPDATEs this way ... no way.
It wouldn't make sense anyway
WHERE
(FIRST_NAME='bob' ...)
AND (FIRST_NAME='bob2' ...)
AND (FIRST_NAME='bob3' ...)
how could FIRST_NAME be eqault to bob AND eqault to bob2 AND eqault to bob3 at the same time/record?
Posted: Tue Aug 01, 2006 6:35 pm
by tam2000k2
You are correct, it was the paren. However, here is the SQL string that doesn't seem to be operating properly. Yet there are no errors reported.
Code: Select all
UPDATE guest_login SET FIRST_NAME= 'bob2', LAST_NAME= 'newhart', EMAIL_ADDRESS= 'bob@newhart.com', WHAT_U_LIKED= 'yes' AND FIRST_NAME= 'bob3', LAST_NAME= 'newhart', EMAIL_ADDRESS= 'bob2@newhart.com', WHAT_U_LIKED= 'yes2' AND FIRST_NAME= 'bob4', LAST_NAME= 'newhart', EMAIL_ADDRESS= 'bob3@newhart.com', WHAT_U_LIKED= 'yes' WHERE (FIRST_NAME='bob' AND LAST_NAME= 'newhart' AND EMAIL_ADDRESS='bob@newhart.com' AND WHAT_U_LIKED='yes') AND (FIRST_NAME='bob2' AND LAST_NAME= 'newhart' AND EMAIL_ADDRESS='bob2@newhart.com' AND WHAT_U_LIKED='yes2') AND (FIRST_NAME='bob3' AND LAST_NAME= 'newhart' AND EMAIL_ADDRESS='bob3@newhart.com' AND WHAT_U_LIKED='yes')
Why is this not working? I guess I have to retrieve the ID which is the unique identifier to make this work. I can do a single update with no problem but multiple rows updates have yet to be successful, but it seems like such an easy process in theory.
Hopefully the last time but thanks in advance
Posted: Tue Aug 01, 2006 7:07 pm
by feyd
How many times do we have to say this?
You cannot update multiple records will differing data with the same update query in the manor you wish.
Posted: Tue Aug 01, 2006 8:23 pm
by Jenk
Code: Select all
UPDATE `guest_login`
SET `FIRST_NAME`= 'bob2' ,
`LAST_NAME` = 'newhart',
`EMAIL_ADDRESS` = 'bob@newhart.com',
`WHAT_U_LIKED` = 'yes'
WHERE `FIRST_NAME` = 'bob'
`LAST_NAME` = 'newhart'
`EMAIL_ADDRESS` = 'bob@newhart.com'
`WHAT_U_LIKED` ='yes'
Code: Select all
UPDATE `guest_login`
SET `FIRST_NAME` = 'bob3'
`LAST_NAME` = 'newhart'
`EMAIL_ADDRESS` = 'bob2@newhart.com'
`WHAT_U_LIKED` = 'yes2'
WHERE `FIRST_NAME` = 'bob2'
`LAST_NAME` = 'newhart'
`EMAIL_ADDRESS` = 'bob2@newhart.com'
`WHAT_U_LIKED`= 'yes2'
Code: Select all
UPDATE `guest_login`
SET `FIRST_NAME` = 'bob4',
`LAST_NAME` = 'newhart'
`EMAIL_ADDRESS` = 'bob3@newhart.com'
`WHAT_U_LIKED` = 'yes'
WHERE `FIRST_NAME` = 'bob3'
`LAST_NAME` = 'newhart'
`EMAIL_ADDRESS` = 'bob3@newhart.com'
`WHAT_U_LIKED` = 'yes'
3 updates, 3 queries.