Ask PHP to do a full-table search of how SQL should be written
Source: Internet
Author: User
What should I write about SQL for full-table search in PHP?
A database, there are many tables (10-30), and then I need to search for the data contained in a field of all the tables below
For example, I need to find all of the following table fields contain Zhang San data.
Normally, I know that when I query MySQL, I look for a single table and a field statement.
SELECT * from name where Name= ' Zhang San ' So, just don't know if the whole table is going to find out how to write SQL
If I use PHP to do this search page
$over =$_post["title";
$sql = "SELECT * from"//How to write it back
------Solution--------------------
Must be done with a program
can refer to the implementation of the "search" function of phpMyAdmin
------Solution--------------------
It's not usually a one-piece look,
Method 1 If the data volume is large, the data can be imported with Sphinx Search, the effect is very fast
Method 2 If the table data does not change too, you can make dozens of tables, synthesize a table, and then find
Method 3 uses the Union
Select content from table1 where name= ' Zhang San '
Union
Select content from table2 where Name= ' Zhang San '
..................
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.