How do I enter a value in the link field that is empty?
How do I enter a value in the link field that is empty?
You can run UPDATE
, but beware! apparently you do not have a single ID
for each field. I have done UPDATE
selecting by name, and this is not correct on that occasion, however it will work, you can change by the field you want to select, follow the code:
UPDATE empresa
SET link = 'https://seusite.com'
WHERE nome = 'Leonardo'
THE RIGHT WAY TO MAKE
A table with auto_increment
and a Primary key.
CREATE TABLE empresa(
ID int NOT NULL AUTO_INCREMENT,
nome varchar(255) NOT NULL,
endereco varchar(255),
cidade varchar(255),
telefone varchar(255),
email varchar(255),
link varchar(255),
PRIMARY KEY (ID)
);
To give INSERT
, it is the same as your table, however you do not need to set ID
because it is automatic.
The UPDATE would look like this:
UPDATE empresa
SET link = 'https://seusite.com'
WHERE ID = 1
So you would not change the city of ALL Leonardo, only Leonardo with ID = 1
that is unique.
UPDATE "table" SET link = "value" WHERE
This way you could already update this data, but as Leonardo quoted, a table without ID is worrisome!
UPDATE empresa
SET link = 'https://link.com'
WHERE nome = 'Linhares'