Error code: 1136. The number of columns does not match the value

The following query causes this error:

Error code: 1136. The number of columns does not match the number of values ​​in row 1.

Why am I getting this error?

SET @id_country = (SELECT id_country FROM prestashop147.ps_country WHERE iso_code = 'br'); SET @id_state = (SELECT id_state FROM ps_state WHERE iso_code = 'mg'); INSERT INTO ps_address(id_address, id_country, id_state, id_customer, id_manufacturer, id_supplier, alias, company, lastname, firstname, address1, address2, postcode, city, other, phone, phone_mobile, vat_number, dni, date_add, date_upd, active, deleted) VALUES (null, @id_country, @id_state, 2, 0, 0, 'Endereço', 'sobrenome', 'nome', 'rua canada, 71', 'complemento', 'cep', 'cidade', null, 'telefone', 'celular', null, null, null, null, 1, 0); 
+4
source share
2 answers

You have 23 columns in INSERT but only 22 VALUES are supplied

+17
source

With a long list of columns like this, you can be better with the INSERT INTO ... SET flavor of INSERT :

 INSERT INTO ps_address SET id_address = null, id_country = @id_country, id_state = @id_state, id_customer = 2, ... and so on 

Note that this is a MySQL extension, not a SQL standard.

+5
source

All Articles