Getting Array with MySQL -
i have form fields name, email, , city. city autocomplete field calls 3 separate tables (cities, regions, countries).
what i'd have these explode array city, region, , country defined values. query right autocomplete field:
select c.city, concat(r.region, ', ', co.country) cities c, regions r, countries co c.regionid = r.regionid , c.countryid = co.countryid , c.city concat( incity, '%' ) order city;
as can see, entered value (incity) compared city column in cities table.
the reason need have city, region, , country defined because need enter ids in table called events. query insert cityid events table:
insert events (events.cityid) values ((select cityid cities city = incity limit 1));
this doesn't work because there multiple cities same name.
i able before php, i'm using mydbr reports , can use queries.
things lot clearer when keep join
conditions out of where
clause:
select concat(c.city, ', ', r.region, ', ', co.country) cities c inner join regions r on c.regionid = r.regioid inner join countries co on c.countryid = co.countryid c.city concat( incity, '%' ) order city;
Comments
Post a Comment