这是简化的查询:
SELECT
`Node`.`id`,
`Node`.`name`
FROM
`localhost`.`nodes` AS `Node`
LEFT JOIN `localhost`.`data_date_times` AS `DataDateTime` ON (
`DataDateTime`.`node_id` = `Node`.`id`
)
LEFT JOIN `localhost`.`data_locations` AS `DataLocation` ON (
`DataLocation`.`node_id` = `Node`.`id`
)
这个 VS 左连接有什么缺点吗?我可以通过子查询的返回值对整个查询的结果进行排序吗?
我尝试格式化此查询:
SELECT
`Node`.`id`,
`Node`.`name`,
(SELECT `data_locations`.`name` FROM `data_locations` WHERE `data_locations`.`node_id` = `Node`.`id`),
(SELECT `data_date_times`.`name` FROM `data_date_times` WHERE `data_date_times`.`node_id` = `Node`.`id`)
FROM
`localhost`.`nodes` AS `Node`
WHERE ???
ORDER BY ???