Comparison of the two types of SQL statements and comparison of the two types of SQL statements
SUM (p. payable-p. single_price) AS profitCount,
M. order_id AS orderId,
M. create_time,
M. dept_airport_code,
M. arrv_airport_code,
M. payable AS price
FROM
Om_passenger p,
Om_order m
WHERE
P. order_id = m. order_id
AND p. ticket_status = '1'
AND m. create_type = 3
AND m. order_status = '20140901'
GROUP
P. order_id
ORDER
M. create_time DESC;
**************************************** **************************
SELECT
SUM (p. payable-p. single_price) AS profitCount,
M. order_id AS orderId,
M. create_time,
M. dept_airport_code,
M. arrv_airport_code,
M. payable AS price
FROM
Om_passenger p,
(
SELECT
*
FROM
Om_order t
WHERE
T. create_type = 3
AND t. order_status = '20140901'
) AS m
WHERE
P. order_id = m. order_id
AND p. ticket_status = '1'
GROUP
M. order_id
ORDER
M. create_time DES
The differences between the two SQL statements are as follows: 1. Join the SQL statement first and then query it in a unified manner; 2. Join the SQL statement after query and then query it at the end. In general, the former one is more efficient, the latter is slower.