In php, we often need to execute SQL statements, so we will use mysql_query to query.
MySQL QuerySo far, we have seen a couple of different uses of PHP's mysql_query function, we will see that almost all the work in PHP MySQL is through the MySQL
Recently, I have been busy developing business systems, and the database has been replaced with Mysql from the original Oracle database. However, I found that SQL Execution was very slow during online operation, what's more strange is that this
: Question: How can I use an SQL statement to query and display the result in format 2? (Ps: There are still many orderids, not just 6). Is it true that SQL statements cannot be processed and can only be processed through php? I have been thinking
Figure One:
Figure II:
Question: How do I make a query of graph one out of SQL statements and show format two? (Ps:orderid There are many, not just 6), is not SQL statement can not be processed, can only be processed by PHP? I've been thinking for
For example, my fuzzy search keyword is "mobile phone", and the table fields in my database include descriptions, prices, regions, etc. I want to determine the keyword "mobile phone" in each field, as long as the keyword & quot; mobile phone & quot;
The following table is available: CREATETABLE 'loginlog' ('id' BIGINT (20) UNSIGNEDNOTNULLAUTO_INCREMENT, 'username' VARCHAR (100) DEFAULTNULL, 'operate' VARCHAR (512) DEFAULTNULL, PRIMARYKEY ('id') ENGINEMYISAMAUTO_INCREMENT1DEFAULTCHARSETgbk has a
Develop the market survey business. there is a survey problem table responses (row 1 million), which is the raw data of the market survey, including survey_id (Type column of the survey table), response_no (column of respondents ), interview_date
Title
6 Table union query, the current use is still a LEFT join B right join C to a LEFT join D to a LEFT join E to a LEFT join F such
In order to ensure that each record in table A is found in the BCEDF table, there are only a few conditions to
MySQL Database
Table TB, with a title field
There is a record for "Emeishan, Leshan quality 2nd Tour"
Another record is "Shanghai 2nd Tour"
There is a fixed string for "Mount Emei, Shanghai, Chengdu, Leshan, Beijing"
How to write a statement can
This is the SQL statement, you should only query to 25 records, see the results of the run
Ask, why
Reply to discussion (solution)
Limit 25, 50Indicates: Outputs 50 rows from the 25th line in the result
The limit clause can be used to limit
MySQL Query statementCommon SELECT commandsPrint the current date and timeSelect Now ();Print the current dateSelect Curdate ();Print Current timeSelect Curtime ();View current versionSelect version ();Print Current UserSelect User ();View Current
Use explain to optimize the query of a Business day summary report. Change a query of type all to range.SQL is a report using:EXPLAINSELECTDate_format (T1.business_date,'%y-%m-%d') asBusiness_date,IF(T3.people_num>0,
Explain shows how MySQL uses indexes to process SELECT statements and join tables. Can help select better indexes and write more optimized query statements.Using the method, add explain to the SELECT statement, such as:Explain select * from Statuses_
If you have a table that looks like this:
ID
name
1
Tom
2
John doe
3
Harry
We generally query multiple data when the condition is usually a certain intervalsuch as: ",",
Index optimization, query optimization, query caching, Server Setup optimization, operating system and hardware optimization, application-level optimization (Web server, caching), and more. Here's the record of the optimization techniques more
From the application examples of most systems, query operation occupies the most proportion in various database operations, and the SELECT statement based on query operation is the most expensive statement in SQL statement. For example, if the
Explain shows how MySQL uses indexes to process SELECT statements and join tables. Can help select better indexes and write more optimized query statements.Using the method, add explain to the SELECT statement, such as:Explain select * from Statuses_
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.