从数据库中检索单个属性的多个值 [英] Retrieve multiple values for single attribute from database

查看:105
本文介绍了从数据库中检索单个属性的多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果一个输入被映射到数据库中的多个输出,那么如何在c#中显示所有输出?我正致力于旁遮普语到英语音译。对于例如ਵੀਰ旁遮普语中的一个单词可以写成veer和vir,并且veer和vir都存储在数据库中,然后如何在输入中同时输出veer和vir ਵੀਰ。



我的尝试:



我我试过多个查询,但它不是一个可行的解决方案。

If one input is being mapped to more than one outputs in database ,then how to display all the outputs in c# ? I am working on punjabi to english transliteration. For e.g. "ਵੀਰ" a word in punjabi can be written as "veer" and "vir", and both "veer" and "vir" are stored in database ,then how to have both the outputs of "veer" and "vir" on input of "ਵੀਰ".

What I have tried:

I am tried with multiple queries but its not a feasible solution.

推荐答案

你需要有一个表格来表示你要翻译的单词 - 例如:
You need to have a table for the words you are going to translate - for example:
create table basewords
(
	id int identity(1,1),
	word nvarchar(125)
)
insert into basewords values ('ਵੀਰ')

然后,链接回该基表的翻译单词表每个base可以有很多条目字。例如:

Then a table for the translation words that links back to that base table can have many entries per "base" word. For example:

create table translated
(
	id int identity(1,1),
	word nvarchar(125),
	transOf int	-- Foreign key back to basewords
)

insert into translated values
('veer',1),
('vir',1)

然后,您可以使用以下简单查询获取匹配的单词:

Then you can get the matching words back with this simple query:

select B.word, T.word as translation
from basewords B
left outer join translated T on B.id=T.transOf

哪会产生结果

word translation
ਵੀਰ  veer
ਵੀਰ  vir


这篇关于从数据库中检索单个属性的多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆