I am not convinced MySql will let you do that like that... A join is fundementally a where clause and you are using techniques that are part of the column select.
You could try something like
SELECT *
FROM `Custom_Pages`
CASE `Custom_Pages`.`City_State`
LEFT JOIN Cities ON ( City_State = 'city' AND Cities.record_number = Custom_Pages.Location )
LEFT JOIN States ON ( City_State = 'state' AND States.record_number = Custom_Pages.Location )
I don't do much MySQL any more but it is valid SQL. I remember this working in MySQL in versions above 4 ( including 4.1 ). Earlier versions would just ignore it. But that will give you at least 1 extra column
Though you are probably better off doing a union, the columns will have to match( or their aliases ) in both statements so you are better of not doing SELECT . Actually you are probably better of never doing a SELECT except when wrapping a UNION.
SELECT *
FROM `Custom_Pages`
JOIN Cities ON ( City_State = 'city' AND Cities.record_number = Custom_Pages.Location )
UNION
SELECT *
FROM `Custom_Pages`
JOIN States ON ( City_State = 'state' AND States.record_number = Custom_Pages.Location )
If you want to order it you have to wrap it.
SELECT * FROM
(
SELECT *
FROM `Custom_Pages`
JOIN Cities ON ( City_State = 'city' AND Cities.record_number = Custom_Pages.Location )
UNION
SELECT *
FROM `Custom_Pages`
JOIN States ON ( City_State = 'state' AND States.record_number = Custom_Pages.Location )
) AS RESULTS /* You need an alias as you are making a table set ) */
ORDER BY City_State
I can't test it but that is the gist.