I have a MySQL Table which is structured like so:
key ID value1 value2
| 1 | | ID1 | |2| |4|
| 2 | | ID2 | |5| |5|
.
.
.
I need to query this table and return just the IDs based on ascending order of the difference between value1 and value 2. If there are equal values then the ID order is irrelevant and can be random. The format of the output is important though. It should be a long string separated by the shown tokenizer. I have:
$query = "Select * From `Table`";
$result = $conn->query($query),
while($row = $result->fetch_assoc()) {
code???
echo $row["ID"]."!@#$";
}
How can I structure the missing code block to accomplish this? I think what I want to do is create a variable which is (value1 - value2) then create an array which stores the id as a key with the result and sort ascending then echo the key. I just don't know how to write it