定制订单由 +分组依据
所以我在这个表中有一本手册:
id lang header_name text
1 uk Youth Development It's very important
2 dk tst hejsa
3 uk tst hello sir
我想进行一个查询来获取给定语言(在本例中为丹麦语)的所有手册条目。如果由于某种原因,原始手册条目(英国的)并未全部 100% 被翻译,我想改为获取英文条目。在这样的表格格式中是否可能?
我猜想这可能是某种“按 header_name 分组”的东西,但不确定。
So I have a manual in this table:
id lang header_name text
1 uk Youth Development It's very important
2 dk tst hejsa
3 uk tst hello sir
And I want to make a query that fetches all manual entries for a given language (danish in this case). If for some reason not all 100% of the original manual entries (the UK ones), has been translated I want to get the english entry instead. Is that even possible in table formats such as this?
I guess it would be something with a "group by header_name" of some sorts, but not sure.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
试试这个,我没有 SQL,因此没有经过测试
表t1、t2、t3指的是同一个表,使用别名来区分;
本质上,首先您需要找到具有翻译的 ID,然后排除它们。
Try this, i dont have an SQL and hence this is not tested
The tables t1, t2, t3 refer to the same table use an alias to distinguish them;
Essentially first you need to find the ID that have translation, and then exclude them.
这可能可以解决问题,但还没有优化:
This might do the trick but it is not optimized:
我无法发表评论,但我想问的是:
在您刚刚提出的示例中,ID 2 和 ID 3 的行是相同的条目,只是语言不同?
我想说你把它拿出来并制作两个表
然后,如果查询 id 1 的示例的丹麦语翻译,它将返回该实体的 example_translations 行。如果没有返回任何内容,您可以查询英文版本。
我认为不可能在 Mysql 级别上做这样的事情
I cant comment but all i want to ask is:
In the example you just put up, the rows with Id 2 and ID 3 are the same entries only different language?
Id say you pull it out and make two tables
Then if querying for the danish translation of an example with id 1 it'll return the example_translations row of this entity. if it returns nothing you can query for the english version.
I dont think it is possible to do something like this on Mysql level
按照我的理解,如果丹麦语内容丢失,您想获取英语内容吗?..您可能想在表格中添加一列来标记条目。 (不知道你的“header_name”列是否对你有效,我猜它也会被翻译?..
无论如何,一个名为“entry_id”的列,其中“tst dk”和“tst uk”都有id以“2”为例,您应该在加载手动时询问“entry_id”并首先查找 dk 条目,如果不存在,则加载 uk 条目。
The way i understand this, you want to get the english content if the danish content is missing?.. You might want to add a column to your table where you mark your entries. (dont know if your "header_name" column does that efectly for you, i'm guessing that as well will be translated?..
Anyway, a column named "entry_id" where "tst dk" and "tst uk" would both have id "2" for an example, you should then when you load you manual ask for the "entry_id" and first look for the dk entry, and if it's not there, load the uk entry.