Modify fields phpMyAdmin

1

I just started working with BDs , and I'm trying to update the value of a field in all rows. That is, in the table FRUITS I have the column color , and I want to put all the fruits have color rojo . The fact is that when trying to do it in sql in this way, it does not leave me.

UPDATE frutas SET color = 'rojo'

And he throws me this error:

UPDATE 'frutas' SET 'id_fruta'=[value-1],'color'=[value-2] WHERE 1

Can someone tell me how I can make the change with an sql statement?

    
asked by miaweb 14.05.2018 в 11:12
source

2 answers

1

From what I see you are using the SQL console that brings phpMyAdmin .

Basically what happens is that you are not using the correct syntax. So if you want the column color to change all its fields to Rojo you must execute the sentence:

UPDATE 'frutas' SET 'Color'='Rojo'; 

In phpMyAdmin you must use the single quotes ' ' for the values of the fields as in this case in color .

Whereas for the names of tables or columns the accent grave '' is used. Maybe it's a bit confusing at first, but you get used to it quickly.

I hope you find it useful.

    
answered by 14.05.2018 / 11:44
source
3

I confirm the setencias both in the PHPMyAdmin console and in the MySQL console as a separate service

UPDATE frutas SET color = 'rojo';

EXPLANATION

When you use the interactive console of phpmyadmin, it puts an example structure for you to carry out the query; The last thing you show is not an error is the example that this tool provides you.

What you should do is write as you like your query and later in the sql tab and in the lower right corner look for the button that says CONTINUE which will allow you to carry out your massive modification; but be careful what I'm putting it to you

THEN SO THAT MY PHP MYADMIN MAKES THAT EXAMPLE?

Simple is telling you that you are going to make a modification but where the id is equal to 1, look

UPDATE frutas SET color = 'rojo' WHERE id = 1;
  

That's the only difference, if you use the where you only affect a row and   if you do not use it, it affects all the records in your table

UPDATE

  

Even if you are working on the php myadmin console, you can use only   for the values that are strings of text or dates the quotes   simple '' you do not need to use inverted ones

    
answered by 14.05.2018 в 11:35