I'm doing it when I get an error Error Code: 1248. Every derived table must have its own alias can anyone help me why is it wrong?

Issue

 SELECT a.telegram_name, a.full_name, a.role_id, a.user_id 
        from tbl_telegram_user a 
         LEFT JOIN ( 
        select a.owner_id, a.owner_name from tbl_agenda as a
        join ( 
         select a.type, a.message, a.status from tbl_message as a 
        join tbl_status as b 
        join (select * from tbl_agenda as a join tbl_message as b
         on a.type = b.type
         where a.type="/mom" and ( current_date BETWEEN from_time and to_time ) is not null)
        on a.status = b.status 
        where b.status_type = 'workLocation' or b.status_type = 'off') as b
     on a.type = b.type 
         where DATE(a.from_time) = DATE('2021-08-10 21:04:02')) as b 
         on a.telegram_name = b.owner_name 
         where b.owner_name is null AND a.user_id <> 0 

Solution

i think in line 9 you forget alias :

SELECT a.telegram_name, a.full_name, a.role_id, a.user_id from tbl_telegram_user a LEFT JOIN ( select a.owner_id, a.owner_name from tbl_agenda as a join ( select a.type, a.message, a.status from tbl_message as a join tbl_status as b join (select * from tbl_agenda as a join tbl_message as b on a.type = b.type where a.type="/mom" and ( current_date BETWEEN from_time and to_time ) is not null) as "your alias" on a.status = b.status where b.status_type = 'workLocation' or b.status_type = 'off') as b on a.type = b.type where DATE(a.from_time) = DATE('2021-08-10 21:04:02')) as b on a.telegram_name = b.owner_name where b.owner_name is null AND a.user_id <> 0

Answered By – shubham

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published