Ask PHP how to write full table search SQL statements

Source: Internet
Author: User
Could you tell me how to write a database for the SQL statement used for full table search in PHP? there are many tables (10-30 ), then, I need to search for the data contained in a field in all the tables below. for example, I need to find all the fields in the table below that contain three pieces of data. Normally, I know the statement select & nbsp; * & nbsp; from & nbsp; name & nbsp; where & nbsp; name zhang san: how should I write the SQL statement used by PHP to perform full table search?
A database has many tables (10-30). then I need to search for the data contained by a field in all the tables below.

For example, I need to find all the fields in the table below that contain three pieces of data.

Normally, I know the statement used to query a single table field in MYSQL.
Select * from name where name = 'zhangsan'. I don't know how to write SQL statements if all the tables are used.

If I use PHP for this search page


$ Over = $ _ POST [''title];

$ SQL = "select * from" // How to write the following code
------ Solution --------------------
Must be completed with a program
See phpmyadmin's "search" function.
------ Solution --------------------
Generally, it is not a single query,

Method 1 if the data volume is large, you can import the data and use sphinx for search.

Method 2 if the table data does not change much, you can combine dozens of tables into one and search

Method 3 use union
Select content from table1 where name = 'Zhang san'
Union
Select content from table2 where name = 'zhangsan'
..................




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.