Finally, I learned how to Access full-site search (mixed product tables and news tables) (images)

Source: Internet
Author: User
This is a big event today! I hope that a long-lasting problem can finally be solved! In the past, when a full-site search for an enterprise website was required, if it was SQL Server, it would use a temporary table to fill the product table and news into a temporary table and then search from the temporary table, if it is access, there is no way, because a lot of information says that access is not supported

This is a big event today! I hope that a long-lasting problem can finally be solved! In the past, when a full-site search for an enterprise website was required, if it was SQL server, it would use a temporary table to fill the product table and news into a temporary table and then search from the temporary table, if it is access, there is no way, because a lot of information says that access is not supported

This is a big event today!

I hope that a long-lasting problem can finally be solved!

In the past, when a full-site search for an enterprise website was required, if it was SQL server, it would use a temporary table to fill the product table and news into a temporary table and then search from the temporary table, if it is access, there is no way, because access does not support temporary tables.

Yesterday afternoon, I used asp.net to create an access project. Repeater does not support paging and access does not support stored procedures. DataSet does not support paging, so we have to find a solution on the SQL statement. After repeated research, I finally found a solution and successfully passed it. In this process, a UNION is used. In this application, UNION merges the two query results of the same table. I thought over and over again, can I merge two different tables together?

After thinking about it, I decided to work on it and find the data of a previous website, which contains two tables: [News] and [Products. Then I tried to merge several fields from two of them. The first problem occurred was that the columns of the Two Queries were different and cannot be merged. This was my negligence. After the correction, I succeeded. My heart is overjoyed. Continue the test immediately, and then add a column named 'T' to identify the source of each column, because the data query results of the two tables need to be merged, however, after the query, it is displayed on the webpage. After clicking it, you should link to different programs to display detailed addresses. Therefore, you need to differentiate them. The final result is the following:

Select Id, [P_Name], [P_Update], 'product' AS t From [product]
UNION ALL
Select id, N_title, N_Update, 'News' AS t From [news]

It should be noted that this result will contain four columns, with four columns named id, P_Name, P_Update, and t respectively. The N_title name is no longer used. So it is the following result.

If you want to get a better result, use the AS alias for the column:

Select Id, [P_Name] AS [Title], [P_Update] AS [PubDate], 'product' AS t From [product]
UNION ALL
Select id, N_title, N_Update, 'News' AS t From [news]

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.