I have the following SQL for my PHP project, I need to receive the Module Status Text to match the status Id in the Module Table, but if the status id value doesn't exist, can I set a value in the SQL? This is a simple Query but Im looking for an efficient solution so I dont have to run 2 seperate queries.
Thanks in advance..
Below is what I have now but it does select the values that are not reference in ModuleStatus.
SELECT m.moduleID, m.moduleDesc,s.statusDesc,
FROM Modules m, ModuleStatus s
WHERE s.statusID = m.statusID
Below is a simplified version of the results Im getting...
Module
+--------+---------+---------+
| ID | Desc | Stat |
+--------+---------+---------+
| 5 | Car | 1 |
+--------+---------+---------+
| 6 | Bike | 2 |
+--------+---------+---------+
ModuleStatus
+--------+---------+
| ID | Desc |
+--------+---------+
| 1 | on |
+--------+---------+
| 0 | off |
+--------+---------+
The results would be
Result
+--------+---------+---------+
| ID | Desc | Stat |
+--------+---------+---------+
| 5 | Car | on |
+--------+---------+---------+
But What I want is
Expect!!
+--------+---------+---------+
| ID | Desc | Stat |
+--------+---------+---------+
| 5 | Car | on |
+--------+---------+---------+
| 6 | Bike | Unknown |
+--------+---------+---------+