Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Bradford, UK
    Thanked 68 Times in 67 Posts

    update query inserting blanks instead of specified values

    update bookings set status ="In Progress" and assignedTo=94 where id=54438
    when I run the query the booking gets updated to a status of "" and assignedTo of 0 - wtf?
    status is enum('New', 'In Progress', 'Booked', 'Cancelled', 'Test')
    assignedTo is int(11)

    There are no errors or anything
    Last edited by NancyJ; 09-25-2012 at 10:44 AM.

  2. #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Saskatoon, Saskatchewan
    Thanked 2,668 Times in 2,637 Posts
    This doesn't look right: status ="In Progress" and assignedTo=94. I'll have to test when I get home, but the mysql documentation doesn't specify that 'AND' is a valid separator for the properties. So if I had to guess it, it is evaluating this in a bit fashion. "String" & NUMBER I would expect would result in 0, so I can see the status being set to nothing. I don't have an explaination of the assignedTo though, as I'm not sure what the precedence for the = to bitwise AND would be (assuming that is the case). I would almost expect that would be SET status = ("In Progress" AND assignedTo=94), but that feels like it needs a test.

    Needless to say, just drop that "and" and replace it with a comma.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts