It would be easier if you created a new table with your php array.
But using your current structure, you can create a temporary/fake table like this
SELECT * FROM (
SELECT 'car' as `id`, 'All Cars' as `label`
UNION
SELECT 'jeep' as `id`, 'All Jeeps' as `label`
) php
So, you can use a query like -
SELECT mm.unique_id,
CASE
WHEN mm.type = 'db_category' THEN dbc.label
WHEN mm.type = 'category' THEN php.label
END as menu_label
FROM mixed_menu mm
LEFT JOIN db_category dbc ON mm.unique_id = dbc.id
LEFT JOIN (
/*Create fake table*/
SELECT 'car' as `id`, 'All Cars' as `label`
UNION
SELECT 'jeep' as `id`, 'All Jeeps' as `label`
) php ON mm.unique_id = php.id
ORDER BY mm.position ASC
here is a SQLFiddle example - http://sqlfiddle.com/#!2/5630cc/5
You would then need to build that fake table using your php array.
EDIT
Since your mixed_menu
and db_category
tables are COLLATION latin1_swedish_ci
, and using SELECT UNION
is defaulting to COLLATION utf8_general_ci
you will need to declare this in your SELECT UNION
SELECT * FROM (
SELECT 'car' COLLATE latin1_swedish_ci as `id`, 'All Cars' COLLATE latin1_swedish_ci as `label`
UNION
SELECT 'jeep' COLLATE latin1_swedish_ci as `id`, 'All Jeeps' COLLATE latin1_swedish_ci as `label`
) php
So now the query would be
SELECT mm.unique_id,
CASE
WHEN mm.type = 'db_category' THEN dbc.label
WHEN mm.type = 'category' THEN php.label
END as menu_label
FROM mixed_menu mm
LEFT JOIN db_category dbc ON mm.unique_id = dbc.id
LEFT JOIN (
/*Create fake table*/
SELECT 'car' COLLATE latin1_swedish_ci as `id`, 'All Cars' COLLATE latin1_swedish_ci as `label`
UNION
SELECT 'jeep' COLLATE latin1_swedish_ci as `id`, 'All Jeeps' COLLATE latin1_swedish_ci as `label`
) php ON mm.unique_id = php.id
ORDER BY mm.position ASC