I'm trying to search for a string in a JSON column type in my database along with searching between two dates, I'm getting this error telling me that my column is unknown when it clearly isn't because I'm setting it using AS
.
My JSON column is data
, and inside of there I'm searching for a string and pulling that out with a certain value which I'm then searching by:
SELECT created_at,
CONCAT("", SUBSTRING(data, LOCATE('my_field', data)+13, 20) ) AS my_field_as_column
FROM applications
WHERE created_at BETWEEN "2021-03-17 00:00:00" AND "2021-03-17 23:59:59"
AND my_field_as_column LIKE '%hello world%'
Why would I get:
Unknown column 'my_field_as_column' in 'where clause'