How do I change everything to a single php value

4

My question is this:

In a table, I have a column named nomecliente .

In this table I have several records, however the column nomecliente of the records are different from each other.

How could I make a mysql_query UPDATE , to select all column records and put a single value to all in that same column?

    
asked by anonymous 29.07.2016 / 21:34

1 answer

8

To set a value for all records in one or more columns just omit WHERE in update. Some databases (like MySQL) have a 'lock' against an update / delete without WHERE because this is usually seen as an error, in doubt it generates a backup of the table to have the data before the change.

UPDATE cliente SET nomecliente = 'sera mesmo'

Let's say the table has the following records

id|nome
1 |fulano
2 |ciclano
3 |beltrano

After this statement UPDATE cliente SET nome = 'mario' the table will look like this:

id|nome
1 |mario
2 |mario
3 |mario
    
29.07.2016 / 21:40