简体   繁体   English

处理数据库中的本地化文本

[英]handling localized text in database

在此处输入图片说明

I have one table rewards that has rewards info, each reward has some basic info such as count, id, title, message & description. 我有一张表奖励 ,其中包含奖励信息,每项奖励都有一些基本信息,例如计数,ID,标题,消息和描述。 To be able to localize we give ID`s to these text items. 为了能够本地化,我们给这些文本项提供ID。

I have another table languages , where we keep all text messages, along with key ID & language ID. 我还有另一种表格语言 ,其中保留所有文本消息以及键ID和语言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. 例如,如果我将语言作为英语传递(语言表中的lang_id为1),它将返回所有带有英语文本的奖励。

How do I do this? 我该怎么做呢?

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

PS when asking questions on stackoverflow, you should show at least some research effort - what you tried and what haven't worked. PS在对stackoverflow提出问题时,您应该至少展示一些研究成果-您尝试了什么,哪些没有成功。 Probably, you do not realise, that if you want to retrieve information from two tables at once, you should use JOIN in sql. 可能您没有意识到,如果要一次从两个表中检索信息,则应在sql中使用JOIN。

Here is a link that might be helpful in your further research: 以下链接可能对您的进一步研究有所帮助:

MySQL Docs MySQL文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM