如何从sql server 2008中的多个表中选择数据 [英] how to select data from multiple tables in sql server 2008

查看:161
本文介绍了如何从sql server 2008中的多个表中选择数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有3个表名为registration,lkg和ukg现在我想要这些表中的总数据。

i使用以下查询

select * from registration,lkg, ukg。

显示输出但所有这些数据显示3次

如何检索此数据

...... .....

谢谢你

i have 3 tables named as registration , lkg and ukg now i want total data from these tables.
i used the following query
select * from registration,lkg,ukg.
it displays out put but all those data displayed in 3 times
how can i retrieve this data
...........
thank you

推荐答案

使用内部联接来减少你的问题
Use Inner Join To Reduce Your Problem


请参阅最近的答案,并按照其中提到的链接进行操作:如何获取来自两个表的数据 [ ^ ]
See this recent answer and follow the link mentioned there : How to get data from two tables[^]


您在此处使用的语法称为隐式交叉连接,它毕竟是交叉连接,为此它显示全部可以从您拥有的表中生成数据组合。你有3个表,你会看到数据3次...

你必须了解SQL连接以及如何使用它们...

http://en.wikipedia.org/wiki/Join_(SQL) [ ^ ]

SQL连接的可视化表示 [ ^ ]
The syntax you are using here is called 'implicit cross join' and that IS a cross join after all and for that it displays all combination of data can be produced from the tables you have. As you have 3 tables you see data 3 times...
You have to learn about SQL joins and how to use them...
http://en.wikipedia.org/wiki/Join_(SQL)[^]
Visual Representation of SQL Joins[^]


这篇关于如何从sql server 2008中的多个表中选择数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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