Hello and welcome to our community! Is this your first visit?
Register
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
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts

    update query inserting blanks instead of specified values

    Code:
    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 09:44 AM.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 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
    •