Summary of simple SELECT query statements in SQL, and SQL SELECT query statements
-- Scott users cannot use it. Use system to log on-- Modify scott account to unlockAlter user scott account unlock;-- Reset the password identified to be recognizedAlter user scott identified by tiger;
-- Select the scott user department
Paging query and SQL paging QueryIn fact, there is no difference between paging query and other queries. The main difference is that the query statement is not available, and paging query may be a little more troublesome. Next we will explain how to implement our paging
SQL like usage fuzzy query and SQL fuzzy query
Fuzzy query:
References: http://www.w3school.com.cn/ SQL/SQL _wildcards.asp
When searching for data in a database, you can use the
SQL query a specified date and time record SQL statement and query an instance
Create a table with the following abc structure:Create table 'cc'. 'loup '('Id' INT (4) not null AUTO_INCREMENT,'Datetimes 'INT (4) NULL,'Ipaddress' VARCHAR (20) NULL,Primary key ('id ')) ENGINE = MYISAMInsert data in batchesInsert into 'lou
SQL query specify date time record SQL statement and query instance
First create a table ABC structure is as followsCREATE TABLE ' cc '. ' Loup ' (' ID ' INT (4) Not NULL auto_increment,' DateTimes ' INT (4) NULL,' IPAddress ' VARCHAR NULL,PRIMARY KEY (' id ')) ENGINE = MYISAMThen BULK INSERT dataINSERT into ' loup '
SQL -- Process Multi-condition query and SQL page query on the page
Two methods are used to process multi-condition queries in the past. The first method is to determine the fields to be filled in the condition, and then determine whether the input parameter is null. If it is null, use 1 = 1 to replace this condition
1.in when the query condition is ListSelectId="getmultimomentscommentscounts"Resulttype="int">SelectMoment_comment_count fromTbl_moment_commentcountwhereMidinchforeachitem="Item"index="Index"collection="List"open="("Separator=","Close=")">#{item}foreach> Select>.1 if the type of the parameter is list, then when used, the collection property must be specified as a list
select id= "findbyidsmap" resultmap="Baseresultmap">
Select
include refi
Query and delete SQL statements of Repeated Records and query SQL statements of records
SQL statement for querying and deleting duplicate records1. Search for redundant duplicate records in the Table. duplicate records are determined based on a single field (peopleId ).Selec
SQL Server quickly generates SQL addition, deletion, modification, and query statements, and SQL addition and DeletionAre you still coding to generate SQL statements? Are you still speechless for SQL statements that are sloppy? Ar
When we query information in the database, we often need to query the information based on the conditions entered by the user. Some conditions are available, but some conditions are unavailable. Therefore, we need to assemble the condition statements. The following method is compiled based on this situation, hoping to help the reader:
String SQL = "select * fr
');
Select patIndex ('% soft', 'sqlserver microsoft ');
Select patIndex ('% so_gr %', 'jsonisprogram ');
10. User-Defined Functions
# View all functions of the current database
-- Query all created functions
Select definition, * from sys. SQL _modules m join sys. objects o on m. object_id = o. object_id
And type in ('fn ', 'if', 'tf ');
# Create a function
If (object_id ('fun _ add', 'fn ') is not null)
Dr
results of multiple SELECT statements together, in which case it is necessary to combine the results of several SELECT statements, for example, to query all the employee information of company A and Company B, and then merge the results of the two queries together. The Union and UNION ALL keywords are used for the merge operation. Format: SELECT statement 1 UNION | UNION All SELECT statement 2 UNION | UNION All ............ Example:
My Date
The first date format we get is this: 2009-2-12 or 2009-3-3 or 2009-10-12, we can do this by combining SQL statements: (three examples)
The code is as follows
Copy Code
@1select * from user where birthday> ' 2009-2-3 ' and birthday
This allows us to find all user information that includes 2009-2-3 and is greater than 2009-2-3.
@2 If that's how we mix it.
The code is as follows
Copy Code
Use pt-query-digest to find the SQL statement that is not suitable, pt-query-digestsql
Overview of pt-query-digest1.
Indexes can be executed more quickly, but there must be unreasonable indexes. If you want to find those indexes that are not very suitable and optimize them before they become problems, you can use the p
First, simple query
SQL (structured query Language) Structured Query language is a database query and programming language for accessing data and querying, updating, and managing relational database systems. ANSI (American National Standards Institute) claims that
SQLServer how to use the T-SQL command to query a database in which tables, convenient table operations, need friends can refer to the next
SQLServer how to use the T-SQL command to query a database in which tables, convenient table operations, need friends can refer to the next
1.
1. query all tables in SQL:
Select TABLE_NAME FROM database name. INFORMATION_SCHEMA.TABLES Where TABLE_TYPE = 'base table' after execution, you can see the names of all tables created by yourself in the database.
2. query all tables and columns in SQL:
Select dbo. sysobjects. name as Table_name, dbo. syscolumns.
Next: T-SQL Dynamic Query (1)--IntroductionObjective:In the development of features, we often encounter scenarios such as the following: The application has a query function that allows the user to select the desired condition in many query conditions. This is also the focus of this series.But sometimes you may find th
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.