3

我有如下查询:

$query = 'select mcf.*, mc.*, o.*, u.*
          from MyConstructionFile mcf
          inner join mcf.MyConstruction mc
          inner join mc.MyConstructionUser o and o.is_owner = true
          inner join o.User u
          where mcf.id in ('.implode(',', $ids).')';

我需要结果的顺序与数组中的顺序完全相同,$ids但我得到的结果是按 ID 排序的,我该怎么做?

4

2 回答 2

7

添加

'order by find_in_set(mcf.id, \''.implode(',', $ids).'\')';

FIND_IN_SET()

于 2013-10-01T11:44:31.920 回答
1

它应该是这样的:

'order by find_in_set(mcf.id, \''.implode(',', $ids).'\')';
于 2013-10-01T11:55:15.550 回答