联接的SQL Server问题 [英] Sql Server Problem for Join

查看:74
本文介绍了联接的SQL Server问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


先生,当我编写带有内部联接的查询时,我遇到了一个问题,它给出了多行,例如如果我在两个表上都有2行,那么它给出了4行数据,如何减少仅两行帮助我

Hi
sir i have a problem when i write a query with inner join then it gives multiple rows like if i have 2 rows on both table then it gives 4 rows data how to reduce only two rows help me

推荐答案

使用一些主键比较可以在where子句中达到完美的条件.
use some primary key comparsion make a perfect condition in where clause.


亲爱的达摩德拉(Dear Dharmendra),
首先,您应该提供查询的完整详细信息.

在这里,您必须使用带有右表和左表的列的一些比较来编写具有``ON''子句的内部联接的查询,例如

如果我有Product和ProductInfo表,并且有一个ProductID,则分别是主键和参考键.因此我的查询将如下所示.

从P.ProductID = Pi.Productid上的Product P内部联接ProductInfo Pi中选择*
Dear Dharmendra ,
First,You should give full details of your query.

here u have to write query with inner join having ''ON'' clause using some comparison of column for right and left table , for e.g.

If i have Product and ProductInfo tables and there is a ProductID is primary key and reference key resp. so my query would be like as following.

select * from Product P inner join ProductInfo Pi on P.ProductID=Pi.Productid


首先,您应该提供查询的完整详细信息.

请参阅下面的链接
http://msdn.microsoft.com/en-us/library/aa213234%28v = sql.80%29.aspx [ ^ ]
First,You should give full details of your query.

refer below link
http://msdn.microsoft.com/en-us/library/aa213234%28v=sql.80%29.aspx[^]


这篇关于联接的SQL Server问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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