MySQL Forums
Forum List  »  Newbie

Re: Using a variable to create a table name
Posted by: Thomas Stieve
Date: October 29, 2017 01:55PM

Hi, so I think I have this solution. I need a world table of all titles in English and countries that have edited this title in English or one of the other languages. I was thinking I could set up a master world table and have all the English titles from the English table in it. I can set up a column for each country:

World Table

Title China Estonia Germany
title y
title x
title z

I can then set up statements to go through each language table and if the titles match in the World table and language table, then set a 1 for that country in the World table if it meets the condition of the edit coming from that country in the language table:

UPDATE World INNER JOIN Estonian
ON World.title = Estonian.en_title
SET World.estonia = 1
WHERE Estonian.country = "Estonia";

UPDATE World INNER JOIN Estonian
ON World.title = Estonian.en_title
SET World.china = 1
WHERE Estonian.country = "China";

The biggest problem here is that the values are in one column in the language tables, but I'd like them as columns in the World table. Also, each title can have a number of countries editing it. What I am proposing works. I am concerned though that this will be a lengthy process. The English table has > 1.7 million titles, so it will take a while to go through each language table and find matching titles and to see if it meets a condition of a country.

This works, and I can start now. But, do you see perhaps an alternative that would take less time? Thanks!

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.