I have a table:
activation
+--------+----------------+
| id | activation_code|
+--------+----------------+
| 0001 | 00111 |
| 0002 | 00110 |
| 0003 | 00100 |
+--------+----------------+
and another table:
device
+--------+--------------+
| id |activation_id |
+--------+--------------+
| 12121| 0001 |
| 12122| 0002 |
| 12123| 0003 |
| 12124| 0004 |
| 12125| 0005 |
+--------+--------------+
how can I get both tables and compare if device.activation_id == activation.id
I want to list these devices separately, see an example:
devices
+--------+----------+
| active |inactive |
+--------+----------+
| 12121| 12124 |
| 12122| 12125 |
| 12123| |
| | |
| | |
+--------+----------+
How can I get an effective solution using internal joint when using PHP?
I have a solution here, but its not very nice:
foreach ($device_query as $res_d) {
foreach ($activation_query as $res_a) {
if ($res_d->activation_id == $res_a->id) {
$is_active = true;
break;
}
else {
$is_active = false;
}
}
}
source
share