What is wrong with this SQL statement?!

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • taroo2ah
    New Member
    • May 2007
    • 5

    What is wrong with this SQL statement?!

    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:

    Code:
    '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.
  • taroo2ah
    New Member
    • May 2007
    • 5

    #2
    Ok, I give up with "user variables". Is there anyway to reverse 2 values of 2 columns of a MySQL database?!!

    Comment

    • werks
      New Member
      • Dec 2007
      • 218

      #3
      Originally posted by 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:

      Code:
      '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?

      Comment

      Working...