Commit 1a3ef851 by zhengxj

finish 优化sql on 20191111 by zhengxj

git-svn-id: svn://192.168.3.233/frms/code/car-service/trunk/car-service@24743 aeb6102e-e053-11e5-9fec-f9ebc45caf4b
1 parent 46601faa
...@@ -72,8 +72,11 @@ CREATE TABLE `sys_order_device` ( ...@@ -72,8 +72,11 @@ CREATE TABLE `sys_order_device` (
--转存订单图片到单独表中 --转存订单图片到单独表中
INSERT into sys_order_file(order_id,file_path,create_time,file_type) INSERT into sys_order_file_copy1(sort,order_id,file_path,create_time,file_type)
SELECT id as order_id,install_location_picture as picture ,create_time ,12 as file_type from sys_order WHERE install_location_picture is not null SELECT @r:= CASE WHEN @order_id = a.order_id THEN @r + 1 ELSE 1 END AS sort,
union SELECT id as order_id,car_picture as picture,create_time ,12 as file_type from sys_order WHERE car_picture is not null @order_id:= a.order_id AS order_id,file_path,create_time,file_type
union SELECT id as order_id,vin_no_picture as picture,create_time ,12 as file_type from sys_order WHERE vin_no_picture is not null from(
order by order_id; SELECT id as order_id,install_location_picture as file_path ,create_time ,12 as file_type from sys_order_copy1 WHERE install_location_picture is not null
union SELECT id as order_id,car_picture as file_path,create_time ,12 as file_type from sys_order_copy1 WHERE car_picture is not null
union SELECT id as order_id,vin_no_picture as file_path,create_time ,12 as file_type from sys_order_copy1 WHERE vin_no_picture is not null
order by order_id)a, ( SELECT @r:= 0, @order_id:= '' ) b;
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!