Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
I googled with "mysql" instead of just "sql"
SELECT table_ID, service_type_ID, service_order,
CASE
WHEN service_type_ID IS NULL THEN CONCAT(table_ID, 0)
ELSE CONCAT(service_type_ID, service_order)
END AS final_order
FROM mod_hotel_services
ORDER BY final_order
SELECT
table_ID, service_type_ID, service_order,
CASE
WHEN service_type_ID IS NULL THEN CONCAT(table_ID, 0)
ELSE CONCAT(service_type_ID, service_order)
END AS final_order,
CASE
WHEN service_type_ID IS NULL THEN table_ID
ELSE service_type_ID
END AS final_where
FROM
mod_hotel_services
WHERE
final_where = "1"
ORDER BY
final_order
[blue]SELECT *
FROM ([/blue]
SELECT table_ID
, service_type_ID
, service_order
, CASE
WHEN service_type_ID IS NULL
THEN CONCAT(table_ID, 0)
ELSE CONCAT(service_type_ID, service_order)
END AS final_order
, CASE
WHEN service_type_ID IS NULL
THEN table_ID
ELSE service_type_ID
END AS final_where
FROM mod_hotel_services
[blue]) as data
WHERE final_where = 1
ORDER
BY final_order[/blue]
+----------+-----------------+----------------------------------+---------------
| table_ID | service_type_ID | service_type_name | service_order
+----------+-----------------+----------------------------------+---------------
| 1 | NULL | service 1 | 1
| 2 | NULL | service 2 | 2
| 4 | 1 | NULL | 1
| 5 | 1 | NULL | 2
| 6 | 1 | NULL | 3
| 7 | 2 | NULL | 1
| 8 | 2 | NULL | 2
+----------+-----------------+----------------------------------+---------------
SELECT table_ID, service_type_ID, service_order,
CASE
WHEN service_type_ID IS NULL THEN CONCAT(table_ID, 0)
ELSE CONCAT(service_type_ID, service_order)
END AS final_order
FROM mod_hotel_services
WHERE
CASE ... ???
END
ORDER BY final_order
+----------+-----------------+----------------------------------+---------------
| table_ID | service_type_ID | service_type_name | service_order
+----------+-----------------+----------------------------------+---------------
| 1 | NULL | service 1 | 1
| 5 | 1 | NULL | 2
| 6 | 1 | NULL | 3
+----------+-----------------+----------------------------------+---------------