mysql 同一条排序语句查询出来的结果某几条没按照排序查询

1501这个机床order 1 2 3 1 2 3 1 2 3 

1502这个机床order 2 3 1 2 3 1 2 3 1

原因是order存在一致的 第一个123 第二个也有123 所以存在随机情况 正常应该是123456 但是需求是123 123 所以再按照id重新排序一下

原sql :select
    bindType.id,
    bindType.process_num as techniqueProcessCode,
    bindType.workpiece_num as workpieceCode,
    bindType.procedure_num as procedureNum,
    machine.position_id as machineToolId,
    bindType.work_order_type_code as largeCategory,
    detail.insert_order as insertOrder,
    detail.`order` as sort,
    detail.select_type_code as workOrderTypeNum,
    detail.trial_subject_code as trialSubject,
    detail.work_order_code as workOrderCode
from
    ims_technique_work_rule_bind_work_type bindType
    INNER JOIN ims_technique_work_rule_bind_work_type_detail detail on bindType.id = detail.work_rule_bind_work_type_id
    INNER JOIN ims_technique_lathe machine ON bindType.machine_id = machine.technique_id
WHERE
    machine.del_flag = 'false'
    and bindType.process_num = '002'
order by
    process_num,
    procedure_num,
    machine_num,
    work_order_type_code

修改后sql: select
    bindType.id,
    bindType.process_num as techniqueProcessCode,
    bindType.workpiece_num as workpieceCode,
    bindType.procedure_num as procedureNum,
    machine.position_id as machineToolId,
    bindType.work_order_type_code as largeCategory,
    detail.insert_order as insertOrder,
    detail.`order` as sort,
    detail.select_type_code as workOrderTypeNum,
    detail.trial_subject_code as trialSubject,
    detail.work_order_code as workOrderCode
from
    ims_technique_work_rule_bind_work_type bindType
    INNER JOIN ims_technique_work_rule_bind_work_type_detail detail on bindType.id = detail.work_rule_bind_work_type_id
    INNER JOIN ims_technique_lathe machine ON bindType.machine_id = machine.technique_id
WHERE
    machine.del_flag = 'false'
    and bindType.process_num = '002'
order by
    process_num,
    procedure_num,
    machine_num,
    work_order_type_code,
    detail.id

修改后sql多了个id排序

  • 4
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值