Dear All,

I am new to MySQL. Can i retrive the result of a query as the combination of different fields of a single record..

For example..
if the result record of a query is ... id(1), country(India), Location1(maharashtra), Location2(pune), Location3(Navi Mumbai)...

My doubt is that can i retrive the 3 locations as one field..

Please excuse me if this is a foolish question..

Regards,

Jino..

Recommended Answers

All 2 Replies

If I understand correctly you want people to search for "muharashtra" or "pune" and get "india" as the result?

What I would do is setup 2 mysql tables in the one database.

1 called "countries"
1 called "cities"

like so:

countries
country_id
country_name

cities
city_id
country_id
city_name

You can now do something along the lines of:

$sql = "SELECT countries.name FROM countries,cities WHERE countries.country_id=cities.country_id AND cities.city_name LIKE '%$SEARCH_STRING%'";

Comprende?

you can try something like this:
SELECT Column1 & ' ' & Column2 AS Name FROM ....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.