Skip to content
Advertisement

Left outer join is working with SQLite while is not with MySQL

I have a table with products, orders, prices, date of sell. I need to create a table with the sells for a product in a single day. I used sqlite and this code worked just fine:

As I said, this code worked pretty fine with sqlite (with “TEMP VIEW” instead of “TEMPORARY TABLE”), but with mysql I get “Every derived table must have its own alias“. So I have added an alias on the last select:

and now I get “Duplicate column name ‘productName’“. Now I’m pretty sure I have tried almost every possible combination of table name and productName, but still can’t get rid of that error.

Advertisement

Answer

In the inner query:

you select all the columns from both tables.
So in the result there are 2 columns named productName from the 2 tables (the same for the column orderDate) and this is not allowed.
In the select list specify only one of each column pair and any other column that you want and drop *:

I used aliases for the table names to shorten the code.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement