将不同表中的数据复制到SQL Server中的一个表中 [英] Copy data from different tables into one in SQL server

查看:107
本文介绍了将不同表中的数据复制到SQL Server中的一个表中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,



我有5个不同的表格让我们说table1,table2,table3,table4,table5。

这些表有一个几个常见的列,如referenceNumber,CNIC Number,Product等。

在我的网页上有一个文本框,用户可以输入CNIC编号,他们可以执行搜索。

我想要什么无论何时在后端执行搜索,查询都应该运行,这将搜索所有表,并且在哪个表中找到CNIC号,它获取记录并在前端显示。

我的问题是如何我应该这样做。

我正在考虑创建一个视图并将每个表中选定的字段放入其中,然后在该视图上执行搜索。另一件事是有些产品我想在网页上突出显示结果。

请在这里帮助我。



我尝试了什么:



通过谷歌搜索但未发现任何相关内容。

解决方案

了解在SQL中加入 [ ^ ]并使用 INSERT INTO ... SELECT ... [ ^ ]

Hello,

I have 5 different tables let's say table1,table2,table3,table4,table5.
The tables have a few common columns like referenceNumber, CNIC Number, Product etc.
At my webpage there is a textbox where user can enter CNIC Number and they can perform searches.
What i want is whenever a search is performed at backend the query should run which will search through all the tables and in which ever table it finds the CNIC Number it fetches the records and display at frontend.
My problem is how should i do it.
I am thinking of creating a view and putting every tables selected fields in it and then perform searching on that view. Another thing is there are some products for which i want to highlight the result in webpage.
Please help me here.

What I have tried:

Searched through google but have not found any relevant thing.

解决方案

Learn about JOINs in SQL[^] and use INSERT INTO ... SELECT ...[^]


这篇关于将不同表中的数据复制到SQL Server中的一个表中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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