I've wrote a query like below in order to insert unique 'project_title' value in the table ('projects').
INSERT INTO projects (projects.project_title, projects.description)
SELECT * FROM (SELECT 'a title', 'a description') AS tmp
WHERE NOT EXISTS (SELECT projects.project_title FROM projects WHERE projects.project_title = 'a title') LIMIT 1
This works fine until a same entry for both project title and project description entered and the query will be like this:
INSERT INTO projects (projects.project_title, projects.description)
SELECT * FROM (SELECT 'text', 'text') AS tmp
WHERE NOT EXISTS (SELECT projects.project_title FROM projects WHERE projects.project_title = 'text') LIMIT 1
Now, I get this error:
[Err] 1060 - Duplicate column name 'text'
How to get rid of this duplication error?!
...SELECT * FROM (SELECT 'text' AS firstText, 'text' AS secondText) AS tmp ....