这是我的查询声明。它们相似但执行时的结果不同。根据我的ORDER BY子句,这两个结果都是有效的。但label_total
列中的顺序不相同
- 第一个SQL语句
SELECT
labels.production_line_id,
prices.`code`,
labels.quantity,
`labels`.`total` AS `label_total`
FROM
`labels`
INNER JOIN `order_details` ON `labels`.`order_detail_id` = `order_details`.`id`
AND `order_details`.`deleted_at` IS NULL
INNER JOIN `prices` ON `prices`.`id` = `order_details`.`price_id`
AND `prices`.`deleted_at` IS NULL
WHERE
`order_details`.`order_id` IN ( '2452' )
AND `labels`.`type` = '0'
AND `labels`.`status` != '7'
AND `labels`.`status` != '8'
ORDER BY
`labels`.`production_line_id` ASC,
`prices`.`code` ASC,
`labels`.`quantity` DESC
- 第二次
SELECT
labels.production_line_id,
prices.`code`,
labels.quantity,
`labels`.`total` AS `label_total`
FROM
`labels`
INNER JOIN `order_details` ON `labels`.`order_detail_id` = `order_details`.`id`
AND `order_details`.`deleted_at` IS NULL
INNER JOIN `prices` ON `prices`.`id` = `order_details`.`price_id`
AND `prices`.`deleted_at` IS NULL
WHERE
`order_details`.`order_id` IN ( '2452' )
AND `labels`.`type` = '0'
AND `labels`.`status` != '7'
AND `labels`.`status` != '8'
ORDER BY
labels.production_line_id ASC,
prices.`code` ASC,
labels.quantity DESC
结果