Problem with UPDATE mysql

Asked

Viewed 713 times

1

I have a problem executing an UPDATE command in my Database...

My table has 2 columns:
-Column 1: link (PK) varchar
-Column 2: varchar status

I need to update only the "statuz" field of my table.

*change the value from "NEW" to "DISPLAYED"

Follow the SQL I’m using:

UPDATE toyota_base SET statuz = 'VISUALIZADO' WHERE link = '/comprar/toyota/etios/1-3-x-16v-flex-4p-manual/4-portas/2013/14102343';

inserir a descrição da imagem aqui

The problem:

The update is not working...I run the command, but it has no effect.

The DBMS output indicates that there was no syntax error and the command was executed, however: 0 Row(s) Afectted

inserir a descrição da imagem aqui

I’m asking you to help me solve this.

2 answers

2


I’ve solved the mystery!

*If someone has this same problem, follow here the solution I found:

Instead of using:

WHERE campo = 'link';

I used:

WHERE campo like '%link%';

Ready!
That way the table was updated as I needed.

inserir a descrição da imagem aqui

  • With this syntax you run the risk of updating a line you do not want. What is the "type" of the LINK column ?

  • @Motta, ptz...this would be a problem. But these link column records are unique as they are Primary key the type is varchar...

  • Is that past example of your solution everything that has a string with "link" in any position would be updated.

  • Got it, thanks for the clarification...but in my case this option served me because the final code of each link is unique, there will be the problem of updating other lines...

1

You can use

TRIM(CAMPO) = TRIM('VALOR')

To remove whitespace, remember that the operator "=" makes an exact comparison and considers whitespace as a character.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.