469,091 Members | 1,156 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

What is wrong with this SQL statement?!

taroo2ah
Enviroment: MySQL 5, PHP 5, Windows, Apache.
Database: MyTable [id, Field1, Field2].
Case: I want to reverse the value of Field1 and Field2 where Field2 = $SomeVal. I have wrote the following statement but it didn't work:

Expand|Select|Wrap|Line Numbers
  1. 'update MyTable set Field1 = @OldField2 := Filed2, Field2 = @OldField1 := Field1 where Field2 = 1250';
Question: What is wrong with the above statement since it allways affects 0 rows knowing that there are many rows with Field2=1250! can anybody help?
Thanks in advance.
Jan 8 '08 #1
2 1088
Ok, I give up with "user variables". Is there anyway to reverse 2 values of 2 columns of a MySQL database?!!
Jan 8 '08 #2
werks
220 100+
Enviroment: MySQL 5, PHP 5, Windows, Apache.
Database: MyTable [id, Field1, Field2].
Case: I want to reverse the value of Field1 and Field2 where Field2 = $SomeVal. I have wrote the following statement but it didn't work:

Expand|Select|Wrap|Line Numbers
  1. 'UPDATE MyTable SET Field1 = @OldField2 := Filed2, Field2 = @OldField1 := Field1 where Field2 = 1250';
Question: What is wrong with the above statement since it allways affects 0 rows knowing that there are many rows with Field2=1250! can anybody help?
Thanks in advance.
Hi there,

Are you updating String or Integer?
Jan 9 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

51 posts views Thread by WindAndWaves | last post: by
6 posts views Thread by Daniel Rudy | last post: by
8 posts views Thread by Brian Basquille | last post: by
1 post views Thread by THY | last post: by
22 posts views Thread by noridotjabi | last post: by
669 posts views Thread by Xah Lee | last post: by
5 posts views Thread by Ryan | last post: by
15 posts views Thread by robert maas, see http://tinyurl.com/uh3t | 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.