i want to create a temporary table on the fly from a result set so that i can run some queries against this resultset.
Here is my sql:
CREATE TABLE temp_table_1 AS (SELECT * FROM A LEFT OUTER JOIN B ON A.id = B.id WHERE B.id IS null);
SELECT QUA.id, QUA.name, QUA.address, QUA.acc, QUA.module, QUA.tag
FROM QUA,temp_table_1
WHERE
QUA.name = temp_table_1.name AND
QUA.acc = temp_table_1.acc AND
QUA.tag = temp_table_1.tag
When i run the first query to create the temp table, I get the error message:
‘Duplicate Colum Name ‘id”
Thanks a lot for your help.
You’re getting both columns
A.idandB.idwithout aliases to differentiate them. Be specific about the columns you select:It’s unwise to use
SELECT *because you can’t always guarantee the order that the columns will return in, if something changed in the originalCREATE TABLEstatement, for example. Also, as you’ve discovered here, similarly named columns will cause problems in many circumstances.