What's wrong with my MySQL code?

1

The error is this: error code 1064. You have an error in your sql syntax;

My code is this:

INSERT INTO pessoa (Endereço, Email, Telefone)
VALUES ('Rua Ernesta de Oliveira Pina', '[email protected]',
'(62) 1234-5678') WHERE PS_NOME='Átila o Encapuzado'
    
asked by anonymous 01.12.2016 / 02:12

1 answer

7

When you use the INSERT in MySQL you can not use the WHERE clause, you do not need to, because the WHERE is to select results, and INSERT does not mess with results, it just creates a new row (or tuple) in the table. / p>

Your code would look like:

Insert into pessoa (Endereço, Email, Telefone) values ('Rua Ernesta de Oliveira Pina', '[email protected]', '(62) 1234-5678') 

Source: link

EDIT

If you want to insert this data in the given row, you are actually doing an UPDATE, not an INSERT.

UPDATE pessoa SET (Endereço='xxxx', Email='ccccc', Telefone='21312321') WHERE nome='Atila blablal'

Something in these lines, so you need to adapt to what you need.

Source in SQL UPDATE: link

    
01.12.2016 / 02:21