Mysql tutorial multi-field keyword fuzzy query method
To query several fields in a mysql SQL statement, we need to use the concat () function of the string join function,
String concat (string, string, string *)
The following function call
Simple view creation, deletion, preview, and other operationsA view is a virtual table whose content is defined by the query. Like a real table, a view contains a series of columns and row data with names. However, a view does not exist in the form
The illegal mix of collations (gbk_chinese_ci, implicit) appears when saving data in the mysql tutorial)
Other such problems are easy to solve, that is, the data submitted on the page is inconsistent with the mysql field type, as long as they are
CaseCalculate the condition list and return one of multiple possible result expressions.
Case has two formats:
The simple case function compares an expression with a group of simple expressions to determine the result.
The case search function
Merge and sort the records of multiple tables as follows:
Select * from (select * from Table
UnionSelect * from Table B
UnionSelect * Table c) as h order by h. List desc
In the database tutorial, the union and union all keywords combine
Two Methods for SQL to calculate the intersection of two tables
Dept table
Id deptid1 202 203 20
User table
Id userid1 332 343 34
Method 1
Select distinct userid
From user u
Where id in (select id from dept where deptid = 20)
Example 1: The table has a primary key (a field that can be uniquely identified) and the field is of the numerical type.
Example 1 test data/* Table Structure */Drop table if exists 't1 ';Create table if not exists 't1 '('Id' int (1) not null auto_
Mysql tutorial this function has none of deterministicThis function has none of deterministic, no SQL, or reads SQL data in its declaration and binary logging is enabled (you * might * want to use the less safe log_bin_trust_function_creators
SQL join on joint query instance
SQL join-use joinIn addition to the above method, we can also use the keyword join to obtain data from two tables.
If we want to list the orders of all users, we can use the following select statement:
Select
SQL union all syntaxTable Name: tableField: id username ytimeThe result to be implemented is:Query 1:Select top 5 * from table where id> 20 order by id ascQuery 2:Select top 5 * from table where id Then, the sum of query 1 and query 2 is sorted in
MySql stored procedure creation and deletion and instance
The stored procedure in the mysql tutorial is a stored procedure with parameters (dynamic execution of SQL statements). The Stored Procedure in mysql queries user information based on user
If you are in mysql version 5 or later, I want to tell you that there are three mysql paging Stored Procedure instances. The stored procedure is supported only after mysql 5.0, now let's take a look at this stored procedure and look at a simple
This article mainly introduces how to add new users to your MySQL database. Because a mysql may have many databases, we need to grant permissions to different databases and enable users, this is necessary.
How to add a new user to your mysql
SQL statements for obtaining the maximum and minimum values
SQL statements for obtaining the maximum and minimum values
If object_id ('tb') is not null drop table tb;GoCreate table tb (Col1 int,Col2 int,Fcount int)Insert into tbSelect 11,20, 1
Three methods to solve MYSQL Chinese garbled characters
Method 3
1> in this article, garbled characters are eliminated in three steps:
> Eliminate page garbled characters,
> Remove Chinese garbled characters from the mysql tutorial,
> Eliminates
Create database database_name to allow PHP to execute the preceding statement, we must use the mysql_query () function. This function is used to send queries or commands to MySQL connections.
Mysql tutorial create database tutorial commands and
For the first execution, the data is not cached in the memory and needs to be read from the hard disk, so it will be very slow. In the second execution, the data has already entered the memory, so it does not need to be read from the hard disk and
In the SQL SQL Aggregate functions that use the same number of statements together provide some database tutorial columns for grouping (the result dataset method ).GROUP
The best way to use SQLGROUPStatement example.
The following database table
Mysql tutorial paging optimization code for massive dataPage indicates the page number.Pagesize indicates the number of entries displayed on each page.Conditon indicates some conditions view sourceprint? 1 select * from table where conditon order by
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