I have searched this issue high and low, and I felt certain that my query is valid. However, I continually get an error. Please help!
I have two tables. One first one is for residential properties. It has 4 columns that the second table doesn't have... I have used NULL AS '...' for each of the missing columns.
SELECT `L_ListingID`, `LA1_AgentID`, `L_Class`, `L_Class_`, `L_Address`, `L_City`, `L_State`, `L_Zip`, `L_AskingPrice`, `L_InputDate`, `L_Status`, `LM_Int1_1`, `LM_Int4_12`, `LM_Char10_12`, `LM_Char10_13`, `LM_Char10_14`, `LM_Char10_15`
FROM `properties_residential`
WHERE 1 AND ( LCASE(TRIM(`L_Address`)) LIKE '%kokomo, in' OR LCASE(TRIM(`L_City`)) LIKE '%kokomo, in' OR LCASE(TRIM(`L_Area`)) LIKE '%kokomo, in' OR LCASE(TRIM(`L_State`)) LIKE '%kokomo, in' OR LCASE(TRIM(`L_Zip`)) LIKE '%kokomo, in' OR LCASE(TRIM(`LM_Char10_12`)) LIKE '%kokomo, in' OR LCASE(TRIM(`LM_Char10_13`)) LIKE '%kokomo, in' OR LCASE(TRIM(`LM_Char10_14`)) LIKE '%kokomo, in' OR LCASE(TRIM(`LM_Char10_15`)) LIKE '%kokomo, in' OR CONCAT ( L_City, ', ', L_State ) LIKE '%kokomo, in%' OR CONCAT ( L_City, ' ', L_State ) LIKE '%kokomo, in%' )
UNION
SELECT `L_ListingID`, `LA1_AgentID`, `L_Class`, `L_Class_`, `L_Address`, `L_City`, `L_State`, `L_Zip`, `L_AskingPrice`, `L_InputDate`, `L_Status`, NULL AS `LM_Int1_1`, NULL AS `LM_Int4_12`, NULL AS `LM_Char10_12`, NULL AS `LM_Char10_13`, NULL AS `LM_Char10_14`, NULL AS `LM_Char10_15`
FROM `properties_commercial`
WHERE 1 AND ( LCASE(TRIM(`L_Address`)) LIKE '%kokomo, in' OR LCASE(TRIM(`L_City`)) LIKE '%kokomo, in' OR LCASE(TRIM(`L_Area`)) LIKE '%kokomo, in' OR LCASE(TRIM(`L_State`)) LIKE '%kokomo, in' OR LCASE(TRIM(`L_Zip`)) LIKE '%kokomo, in' OR LCASE(TRIM(`LM_Char10_12`)) LIKE '%kokomo, in' OR LCASE(TRIM(`LM_Char10_13`)) LIKE '%kokomo, in' OR LCASE(TRIM(`LM_Char10_14`)) LIKE '%kokomo, in' OR LCASE(TRIM(`LM_Char10_15`)) LIKE '%kokomo, in' OR CONCAT ( L_City, ', ', L_State ) LIKE '%kokomo, in%' OR CONCAT ( L_City, ' ', L_State ) LIKE '%kokomo, in%' )
ORDER BY `L_InputDate`
DESC LIMIT 6
And the error is...
1054 - Unknown column 'LM_Char10_12' in 'where clause'
Someone please, point me in the right direction. I greatly appreciate any help.