-1

I tried to us IN to call multiple ids.. but the arrangement of ids are not the same..

here's my sample code:

$sample = "1,3,2,4,5";
$sql_top = "SELECT * FROM team_member WHERE pgs_team_member_id IN ($sample)";

the output that i get: 1 2 3 4

the out that want to get: 1 3 2 4 5

ivor
  • 307
  • 1
  • 6
  • 16

2 Answers2

2

You can try order by, like this:

order by field(pgs_team_member_id, $ids);
Jin.C
  • 121
  • 5
1

you can uese order by field(Order by FIELD in MYSQL)

$sample = "1,3,2,4,5";
$sql_top = "SELECT * FROM team_member WHERE pgs_team_member_id IN ($sample) order by field(pgs_team_member_id,$sample)";
Community
  • 1
  • 1
suibber
  • 267
  • 1
  • 6