Altaf Navalur
Altaf Navalur

Reputation: 3

handling localized text in database

enter image description here

I have one table rewards that has rewards info, each reward has some basic info such as count, id, title, message & description. To be able to localize we give ID`s to these text items.

I have another table languages, where we keep all text messages, along with key ID & language ID.

What I need is a query to get all rewards along with localized text from the table. For example, if I pass language as English (lang_id is 1 in language table), it should return all rewards with English text.

How do I do this?

Upvotes: 0

Views: 476

Answers (1)

Inna Tichman
Inna Tichman

Reputation: 626

select * from
rewards, languages
where rewards.id = languages.key_id   
and languages.lang_id = 1;

P.S. when asking questions on stackoverflow, you should show at least some research effort - what you tried and what haven't worked. Probably, you do not realise, that if you want to retrieve information from two tables at once, you should use JOIN in sql.

Here is a link that might be helpful in your further research:

MySQL Docs

Upvotes: 2

Related Questions