如何从sql server 2008中的多个表中选择数据

如何从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[^]