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
Mandatory SQL statement (6) Data Query and SQL statement Data Query
1. Basic Query1) rename a columnSelect name as 'name' from Table name2) define constant ColumnsSelect = 'is 'From table name3) top usage: percent-- In this way, you can obtain the first 20% fields.Select top 20 percent * from Table Name4) Remove duplic
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
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 '
silent unlocked unlocked Unlocked update NOLOCK unlocked unlocked unlocked unlocked HOLDLOCK shared share share update UPDLOCK error update update update TABLOCKX error unlocked Lock updates Other unlocked unlocked unlocked updates * Specifies that the NOLOCK prompt will cause the table specified for that hint to be read-only in Gianpene.
16, with Profiler to track the
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
unlocked unlocked not locked NOLOCK unlocked unlocked unlocked HOLDLOCK shared share share update UPDLOCK error update update TABLOCKX error Unlocked not Lock update other unlocked unlocked Unlocked update * Specifies that the NOLOCK hint will make the table specified with this hint read-only in cursor.16, use Profiler to track the query, get the time required t
(NOLOCK) WHERE DateDiff (d,o.deliverysigndate,getdate ()) = @OrderIntervalDays-The order has been signed for 7 days and O. CreationDate >= @OrderDate and o.province in (310000,320000,330000) Group by O.userid)--Go to possibly repeat UseriDselecttemp. UserID Userid,max (TEMP. OrderID) Orderid,max (TEMP. Mobile) Mobilefrom TEMPLeft joins Spikeactivityorderrequest so with (NOLOCK) on (TEMP. Userid=so. UserID
prompt in the SELECT statement of the cursor. Lock prompt read-only optimistic value optimistic row version control lock No prompt not locked update NOLOCK not locked HOLDLOCK sharing update UPDLOCK error Update TABLOCKX Error unlocked unlocked update other unlocked update * The specified NOLOCK prompt will make the table specified with this prompt read-only in the cursor.
16. Use Profiler to track the
lock prompt in the SELECT statement of the cursor. Lock prompt read-only optimistic value optimistic row version control lock No prompt not locked update nolock not locked holdlock sharing update updlock error Update tablockx Error unlocked unlocked update other unlocked update * The specified nolock prompt will make the table specified with this prompt read-only in the cursor.
16. Use profiler to track th
lock No prompt not locked update NOLOCK not locked HOLDLOCK sharing update UPDLOCK error Update TABLOCKX Error unlocked unlocked update other unlocked update * The specified NOLOCK prompt will make the table specified with this prompt read-only in the cursor.16. Use Profiler to track the query, obtain the time required for the
locked NOLOCK unlocked unlocked unlocked HOLDLOCK shared share share update UPDLOCK error update update TABLOCKX error unlocked unlocked Fixed update other unlocked unlocked Unlocked update * Specifies that the NOLOCK hint will make the table specified with this hint read-only in cursor.16. Use Profiler to track queries, get the time needed to query, find out th
unlocked not locked updates * Specifying the NOLOCK hint will make the table with the hint specified in cursor read-only. 16, use Profiler to track the query, get the time required to query, find out the problem of SQL; optimizing indexes with the index optimizer17, pay attention to the difference between union and Un
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
control lock No prompt not locked update NOLOCK not locked HOLDLOCK sharing update UPDLOCK error Update TABLOCKX Error unlocked unlocked update other unlocked update * The specified NOLOCK prompt will make the table specified with this prompt read-only in the cursor.16. Use Profiler to track the query, obtain the time required for the
optimistic row version control lock No prompt not locked update nolock not locked holdlock sharing update updlock error Update tablockx Error unlocked unlocked update other unlocked update * The specified nolock prompt will make the table specified with this prompt read-only in the cursor.
16. Use profiler to track the query, obtain the time required for the
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.