Reputation: 1
So im having some trouble with my database right now, I can't seem to update a variable, Im just looking to do a simple "UPDATE" query, this is what it looks like:
So very simple table and all I am looking to do is update the "Sent" column from no to yes.
I've been using UPDATE but for some reason this dosn't work, no syntax error just says 0 rows affected and nothing changes...
UPDATE `numbers` SET `Sent`='True' WHERE `fName`='John';
(Im hoping to change the sent value of all rows containing fName = John.... As you can see in my table John is a value in the database so this should work but for some reason doesn't) Could anyone explain why my statement is wrong and what I am not doing right?
Upvotes: 0
Views: 165
Reputation: 1269733
You need to debug this. Start with the select
query:
SELECT n.*
FROM numbers n
WHERE fName = 'John';
This should return no rows -- meaning that what you see is not what you got. One common problem are invisible characters at the beginning, end, or both (often just spaces). So you can try:
WHERE fName LIKE '%John'
WHERE fName LIKE 'John%'
WHERE fName LIKE '%John%'
Once you figure out what works, you can figure out what to use in the UPDATE
or how to fix the data.
Upvotes: 1