内连接为列提供多个值 [英] Inner join giving columns multiple values

查看:72
本文介绍了内连接为列提供多个值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最爱

我在数据库中有三张桌子



表:组



同上,姓名

表:医生



Id,DId,DoctorName,

表:比率



Id,UpLimit,downLimit。

当我内心加入它们时,我正在获取Uplimit和downlimit的重复值,



实际上,群组与医生有关,一个群组ID可以有多位医生,所以当我用群组和医生保存一些数据时,它会保存到具有相同数据的所有记录,uplimit downlimit因不同的医生而异,但是当我内心加入它对所有医生显示相同时,如何跳过uplimit和downlimit如何写查询..



从A组中选择A.Group,B.doctor,C.Uplimit,D.downlimit

内联医生B

A.id = B.id

内部加入比率a

on A.id = c.id

问题是当我在医生中单独检查医生ID表它只显示一条记录,当我内部加入时,它向所有医生显示相同的数据,特别是如何加入它们?



我有什么试过:



从A组中选择A.Group,B.doctor,C.Uplimit,D.downlimit

inner加入医生B

on A.id = B.id

内连接率c

on A.id = c.id

favorite
I have Three Tables In Database

Table : Group

Id, Name
Table : doctor

Id ,DId, DoctorName,
Table : Ratio

Id , UpLimit , downLimit.
When i inner join them , I am Getting duplicate Values to Uplimit and downlimit,,

Actually Group is related to doctors, One group id can have multple doctors,, so when i save some data with Group and doctor, it is saving to all the records with same data, uplimit downlimit varies with different doctors , but when i inner join dem its showing same to all doctors,, how to skip uplimit and downlimit how to write the Query..

Select A.Group , B.doctor , C.Uplimit, D.downlimit from Group A
inner join Doctor B
on A.id = B.id
inner join ratio c
on A.id = c.id
issue is When i separately check it with doctor id in doctor table it is showing only one record, when i inner join them its showing same data to all doctors to particular how to join them??

What I have tried:

Select A.Group , B.doctor , C.Uplimit, D.downlimit from Group A
inner join Doctor B
on A.id = B.id
inner join ratio c
on A.id = c.id

推荐答案

根据您的反馈,您似乎不确定您的数据库设计。例如,比率表的目的是什么?如果每个医生都有自己的上限和下限,他们可以简单地包含在医生表中,然后就不需要比率表了。建议您参考用户要求重新查看数据库设计。一些参考帮助:

1. 数据库设计简介 [ ^ ]

2. 数据库规范化中的1NF,2NF,3NF和BCNF [ ^ ]

Only在解决了数据库设计问题之后,你应该继续进行编码。
Based on your feedback, it appears that you are not certain about your database design. For example, what is the purpose of the ratio table? If every doctor has his own uplimit and downlimit, they can simply be included in the doctor table, then there is no need for the ratio table. Suggest you re-look into your database design with reference to user requirements. Some references to help:
1. Introduction to database design[^]
2. 1NF, 2NF, 3NF and BCNF in Database Normalization[^]
Only after the database design issues are ironed out, should you proceed with coding.


这篇关于内连接为列提供多个值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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