mysql-dependent-subquery

MySQL - can I avoid these correlated / dependant subqueries?

岁酱吖の 提交于 2019-12-11 20:39:17
问题 I have a MySQL query that I have been optimising, and currently it has 2 dependent / correlated subqueries. I was wondering if it was possible to re write to avoid these? SELECT * FROM `pp_slides` JOIN `pp_slide_content` ON `pp_slides`.`id` = `pp_slide_content`.`slide_id` AND `pp_slide_content`.`version` = ( SELECT max(`version`) FROM `pp_slide_content` WHERE `slide_id` = `pp_slides`.`id` ) LEFT JOIN `pp_published_slides` ON `pp_published_slides`.`slide_id` = `pp_slides`.`id` AND `pp

What is the error “Every derived table must have its own alias” in MySQL?

孤人 提交于 2019-11-25 21:48:20
问题 I am running this query on MySQL SELECT ID FROM ( SELECT ID, msisdn FROM ( SELECT * FROM TT2 ) ); and it is giving this error: Every derived table must have its own alias. What\'s causing this error? 回答1: Every derived table (AKA sub-query) must indeed have an alias. I.e. each query in brackets must be given an alias ( AS whatever ), which can the be used to refer to it in the rest of the outer query. SELECT ID FROM ( SELECT ID, msisdn FROM ( SELECT * FROM TT2 ) AS T ) AS T In your case, of