1060 - Duplicate column name 'NULL' in a Mysql query

Asked

Viewed 293 times

1

I am trying to execute this query, and it always gives me the following error:

1060 - Duplicate column name 'NULL'

INSERT INTO ce_coins_issued (idc, idu, year, ltr, issuing, status)
SELECT * FROM (SELECT 2,1,2002,NULL,NULL,'wallet') AS tmp
WHERE NOT EXISTS
(SELECT idc, idu, year, ltr, issuing, status FROM ce_coins_issued
WHERE idc   = 1 AND year = 2002 AND ltr = NULL LIMIT 1)

The table is allowing fields to NULL, since it has given permission. As I realized, what makes this error is to have two NULL’s in SELECT, because if you remove one of them, the query already runs smoothly.

They can help why?

1 answer

3


do so:

(SELECT 2,1,2002,NULL as ltr,NULL as issuing,'wallet')

assigning an alias, no duplicity will occur

  • 1

    Thank you so much for your help!! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.