用于重复行或列的SQL查询 [英] SQL query used for duplicate rows or columns

查看:85
本文介绍了用于重复行或列的SQL查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下表

i have the following table

diseasename:A symptomlist:a1,a2,a3
diseasename:B symptomlist:b2,a1,c2
diseasename:B symptomlist:b3,a1,c2,a3 


然后我想检索疾病名称以动态输入症状列表
当他们恢复疾病时,它就算出疾病.如果症状列表的输入为:a1,b2,c2
输出是:


Then i want to retrieve disease name for dynamic input of symptom list
when they retrieve the disease it counts the disease eg. if the the input of symptom list are :a1,b2,c2
the out put is:

count=1        diseasename=A
count=3        diseasename=B
count=1        diseasename=C


请帮助"
sql查询,对表进行规范化,任何代码或任何有用的信息都可以.

感谢您的建议


"please help"
sql query ,normalizing the table, any code or any useful information is ok.

THANK U FOR U''R ADVICE

推荐答案

请购买一本好书,以了解数据库.它将帮助您设计数据库,编写查询等.

对于您发布的查询,这是您可以采取的第一步:

MstDisease
Column1 Column2
1疾病-A
2疾病-B
3疾病-C

MstSymptom

Column1 Column2
1个a1
2个a2
3 b1
4 b2
5 c1
6 c2

TrnDiseaseSymptom
Column1 Column2
(MstDisease ID)(MstSymptom ID)
1 1
1 4
2 2
2 4
2 6
3 1
3 3
Please buy a good book to learn about databases. It will help you in Designing databases, writing queries, etc.

For the query you posted, here is one of the start that you can take:

MstDisease
Column1 Column2
1 Disease-A
2 Disease-B
3 Disease-C

MstSymptom

Column1 Column2
1 a1
2 a2
3 b1
4 b2
5 c1
6 c2

TrnDiseaseSymptom
Column1 Column2
(MstDisease ID) (MstSymptom ID)
1 1
1 4
2 2
2 4
2 6
3 1
3 3


这篇关于用于重复行或列的SQL查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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