matthewdacruz
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
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
Your explanation is not clear to me. Can you provide a specific example of what you would like to happen?
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I great I see how you do it. Thanks
ASKER
Thanks for the help