Man utd Man utd - 5 months ago 23
MySQL Question

Every derived table must have its own alias mysql

I have a temporary table named Days created as

CREATE TEMPORARY TABLE days (start_date DATETIME)as
SELECT DATE_ADD(begin_date, INTERVAL n - start_health_post_id DAY) as
start_date FROM NOF
ORDER BY n
LIMIT nofdays;


Now I want to have a cross join with a bunch of select statements that perform inner join

So, I tried this ways

Select * from days
cross join
(
Select practices.*, providers.*, practice_locations.*
from practices
Inner Join providers on practices.health_post_id = providers.health_post_id
Inner join practice_locations on practices.health_post_id =practice_locations.health_post_id
);


But It gives an error saying , every derived table must have its own alias.

please help!

Answer

Set an alias for your sub-query like:

Select * from days
cross join
(
Select practices.*, providers.*, practice_locations.*
from practices
Inner Join providers on practices.health_post_id = providers.health_post_id
Inner join practice_locations on practices.health_post_id =practice_locations.health_post_id
) t1;

I set t1 as alias.