472,101 Members | 1,461 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,101 software developers and data experts.

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 1144
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

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.