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

1

I'm trying to run 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 be NULL, since they have given permission. So I realized, what makes this error is to have two NULL's in the SELECT, because if you remove one of them, the query already executes without problems.

Can you help why?

    
asked by anonymous 30.07.2017 / 14:55

1 answer

3

do so:

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

Assigning an alias, no duplicity will occur

    
30.07.2017 / 15:11