I have the following data in my database table.
rec_id description parent_id ip_address is_parent
100 Record 1 1000 80.160.4.5 1
101 child 1000 169.60.5.20 0
105 child 1000 169.60.5.20 0
103 Record 2 1002 80.160.4.3 1
104 child 1002 169.60.2.5 0
102 Record 3 1001 80.160.4.2 1
I want a sorting based on the column: ip_address of records where is_parent = 1
The parent record should be listed first and the corresponding child should list immediately after the parent.
The result should be as given below:
rec_id description parent_id ip_address is_parent
102 Record 3 1001 80.160.4.2 1
103 Record 2 1002 80.160.4.3 1
104 child 1002 169.60.2.5 0
100 Record 1 1000 80.160.4.5 1
101 child 1000 169.60.5.20 0
105 child 1000 169.60.5.20 0
Can anyone please help me to achievethe above result?