mySQL UPDATE query returns “0 rows affected”

后端 未结 11 1093
感情败类
感情败类 2020-12-05 18:39

I have this query:

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

My table is phonecalls, I

相关标签:
11条回答
  • 2020-12-05 19:04

    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.

    0 讨论(0)
  • 2020-12-05 19:05
    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?
    0 讨论(0)
  • 2020-12-05 19:08

    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.

    0 讨论(0)
  • 2020-12-05 19:14

    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.

    0 讨论(0)
  • 2020-12-05 19:16

    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

    0 讨论(0)
提交回复
热议问题