Skip to content
Advertisement

StartDate invalid identifier

I have two SELECT statment which I connect using UNION and I get error

Since I create first one SELECT statment and run and I get result, and second also, so I run separatly and it works perfect. But when I use UNION I get error pusd2.StartDate invalid identifier.

What is wrong here ? What I made wrong ?

Table structure project_users_schedule_dates

enter image description here

Advertisement

Answer

The error likely stems from using an alias in the second union in your ORDER BY clause. However, I might suggest writing your query this way instead:

This approach brings together the critera from both sides of the union in a single WHERE clause. It then filters duplicates using DISTINCT, instead of the union. Note that in general doing SELECT * in a union query is not desirable, because it makes it impossible to see which columns are being included.

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