1

I have an example like this:

code | name
a    | Pencil
b    | Pen
d    | Ruler
g    | TipeX

-

no | data  | list_order
1  | b,d,a | 2,3,1
2  | g,b,a | 3,2,1

So when run the query the data will be like this:

no | data | list_order
1  | b    | 2
1  | d    | 3
1  | a    | 1

Then I can sort it by list_order ASC

no | data | list_order
1  | a    | 1
1  | b    | 2
1  | d    | 3

My question, is it possible to get the query like above?

*I'm using Oracle DB

$q_data = oci_parse($c1, "SELECT * FROM DATAS WHERE NO = '1'");
oci_execute($q_data);
$row = oci_fetch_array($q_data);
$cp_array = implode(",",array($row['data']));
$cp_list_order = implode(",",array($row['list_order']));

$q_data_cp = oci_parse($c1, "SELECT * FROM DATAS_DTL WHERE no IN ($cp_array)");
oci_execute($q_data_cp);
while($d_data = oci_fetch_array($q_data_cp))
{
     $d_no = $d_data['no'];
     $d_name = $d_data['name'];
     ?>

     <div><?php echo $d_name; ?></div>

<?php
}

Thanks.

HiDayurie Dave
  • 1,791
  • 2
  • 17
  • 45

1 Answers1

0

I don't use oracle db, but I use sql server and I think they both are similar in a lot of ways.

Try to do the following:

Community
  • 1
  • 1
Anderson Silva
  • 709
  • 1
  • 7
  • 31