Go Back   CodingForums.com > :: Server side development > MySQL

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 09-25-2012, 09:23 AM   PM User | #1
NancyJ
Senior Coder

 
NancyJ's Avatar
 
Join Date: Feb 2005
Location: Bradford, UK
Posts: 3,162
Thanks: 19
Thanked 65 Times in 64 Posts
NancyJ will become famous soon enough
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
__________________
http://www.hazelryan.co.uk

Last edited by NancyJ; 09-25-2012 at 09:44 AM..
NancyJ is offline   Reply With Quote
Old 09-25-2012, 06:55 PM   PM User | #2
Fou-Lu
God Emperor


 
Fou-Lu's Avatar
 
Join Date: Sep 2002
Location: Saskatoon, Saskatchewan
Posts: 15,650
Thanks: 4
Thanked 2,451 Times in 2,420 Posts
Fou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to allFou-Lu is a name known to all
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.
Fou-Lu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:45 AM.


Advertisement
Log in to turn off these ads.