Link to home
Start Free TrialLog in
Avatar of matthewdacruz
matthewdacruzFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Looping through a database query

Hi Experts

I have two tables
keywordmodifiers
uk_england = cities and towns

I want to write a query that takes a keywords and adds then to the county of the uk_england table.

The result should end up being [keyword modifier county]
I want this to loop all the way through the uk_england table and add each keywordmodifier keyword till completion.
The table structures are below

How do you write a looping staement in mysql to do this?

Thanks
keywordmodifiers
 
SELECT
keywordmodifiers.keyword,
keywordmodifiers.pg_id
FROM
keywordmodifiers
 
uk_england
 
 
SELECT
uk_england.id_eng,
uk_england.county,
uk_england.town,
uk_england.postcode,
uk_england.Country
FROM
uk_england

Open in new window

Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Your explanation is not clear to me.  Can you provide a specific example of what you would like to happen?
Avatar of matthewdacruz

ASKER

HI routinet

I have a table with keywords. For the example say 10 keywords.
I have another table with cities in it. For the example say it have 100 cities.

I want to take write a query that will add the 100 cities to each of the 10 keywords.

for example: keywords = porche
                     city           =  new york

I would like the result to join the two into a phrase "porche new york", "porche miami", "porche california" and so forth till all cities are added. Then it loops and starts with the next keyword.

I hope this is clearer

Thanks

Matt
ASKER CERTIFIED SOLUTION
Avatar of Steve Bink
Steve Bink
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I great I see how you do it. Thanks
Thanks for the help