I have a form with the fields Name, Email, and City. City is an autocomplete field that calls 3 separate tables (Cities, Regions, Countries).
What I'd like to do is to have these explode into an array so that City, Region, and Country are all defined values. This is my query right now for the autocomplete field:
SELECT c.City, concat(r.Region, ', ', co.Country)
FROM Cities c, Regions r, Countries co
WHERE c.RegionID = r.RegionID and c.CountryID = co.CountryID and c.City like CONCAT( inCity, '%' )
ORDER BY City;
As you can see, the entered value (inCity) is only compared to the City column in the Cities table.
The reason I need to have the City, Region, and Country defined is because I need to enter their IDs in another table called Events. This is my query to insert the CityID into my Events table:
INSERT INTO Events (Events.CityID)
VALUES ((SELECT CityID FROM Cities WHERE City = inCity LIMIT 1));
This also doesn't work because sometimes there are multiple cities with the same name.
I was able to do this before with PHP, but I'm currently using myDBR reports to do this and I can only use queries.