Hi,
I'm putting an autocomplete textbox on my website to help users type in a location. I want users to be able to type a city or just a state (ex. Seattle, WA or Washington) kind of like what you see on Indeed (http://www.indeed.com). How do I get the states to show up by themselves(ex. Washington)? Right now, if there's a job in Seattle then "Washington" by itself will not show up in the suggestions. If we have no jobs in Montana then "Montana" shows up in the suggestions. I want all the states to show up in the suggestions whether we have jobs in the state or not. Hopefully, that makes sense. Please help me tweak the MySQL statement below. I have two tables:
jobs
job_type
city
state_id
states
state_id
name
postal
Current MySQL - $location is the value that the user types in the text box
SELECT j.city AS city,st.postal AS state_prefix,st.name AS state FROM states st LEFT JOIN jobs j ON j.state_id=st.state_id WHERE j.city LIKE '%$location%' OR st.name LIKE '%$location%' GROUP BY j.state_id,j.city ORDER BY j.city ASC,st.name ASC LIMIT 10