tags:

views:

108

answers:

6

I have this query:

UPDATE phonecalls 
   SET Called = "Yes" 
 WHERE PhoneNumber = "999 29-4655"

My table is phonecalls, I have a column named PhoneNumber. All I want to update is a column named Called to "yes".

Any idea what I am doing wrong? when I return my query it says 0 rows affected.

A: 

Try select count(*) from phonecalls where PhoneNumber = "999 29-4655"; That will give you the number of matching rows. If the result is 0, then there isn't a row in the database that matches.-

amphetamachine
A: 

Check to make sure this returns some result.

SELECT * FROM phonecalls WHERE PhoneNumber = '999 29-4655'

If it doesn't return any result than the filter WHERE PhoneNumber = '999 29-4655' is not correct.

Yada
mysql understands both, single and double quotes.
Cassy
The select returns fine
Mike
+1  A: 

The problem might be that there are no records with PhoneNumber == "999 29-4655".

Try this query:

SELECT * FROM phonecalls where PhoneNumber = '999 29-4655'

If it doesn't return anything, then there are no rows that match.

ryanprayogo
The select returns fine
Mike
+7  A: 

As amphetamine and Yada suggested, check with a SELECT, if your phone number is in the table.

But keep in mind: If the value for called of the row in question is already "Yes", mysql won't change the value and will therefore return "0 rows affected". So be sure to also check the current value of called

Cassy
The select returns fine
Mike
What about the second paragraph of his answer?
Pekka
A: 
  1. Does it say Rows matched: 1 Changed: 0 Warnings: 0? Then maybe it's already set to that value.
  2. Did you try single quotes vs. double quotes?
  3. "999 29-4655" is the space a space or a tab and is it consistent in your query and the database?
goharma
A: 

That's my sugestion:

UPDATE `phonecalls` SET `Called` = 'yeah!' WHERE `PhoneNumber` = '999 29-4655' AND `Called` != 'yeah!'

And make sure with the case-sensitive name of table and field`s.

TiuTalk