Mysql-amp; gt; SQL statement to delete duplicate data bitsCN.com
Mysql-> SQL statement: delete duplicate data
A question frequently asked during the interview: an SQL statement is used to delete duplicate data in the table.
Occasionally, when I talked to my colleagues about this issue, I wrote the code for your reference ~
// Data preparation
Mysql code
Drop
MySQL build table statement, MySQL build table statement
1 DROP TABLE IF EXISTS' NuVue ';2 3 CREATE TABLE' NuVue ' (4' ID 'INT(Ten) UNSIGNED not NULLAuto_increment,5' Status 'TINYINT(2) UNSIGNED not NULL DEFAULT 0COMMENT'Status',6' UID 'INT(Ten) UNSIGNED not NULLCOMMENT'Create user',7' province_id 'TINYINT(3) UNSIGNED not NULLCOMMENT'first-class city',8' city_id 'TINYINT(3) UNSIGNED not NULLCOMMENT'Level T
Cakephp is used to print SQL statements. Cakephp: how to print SQL statements. This document describes how to print SQL statements by cakephp. Share it with you for your reference. The specific implementation method is as follows: the following statement cakephp is used to print the SQL statement, cakephpsql statement
This example describes how to print SQL st
ArticleDirectory
Summary:
After the customer's system was upgraded today, we checked through the dmvs performance analysis. After the upgrade, we found that the execution of a statement takes several seconds. The Calling statement is as follows:
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
Select
Distinct
Field003
From
Ufi2j0
Python learning: if statement and pythonif statement
Example:
age = 20if age >= 18 : print 'Adult'elif age
A computer can perform a lot of automated tasks because it can perform conditional judgment on its own.
For example, input the user's age and print different content according to the age. In the Python program, useifStatement implementation:
age = 20if age >= 18: print 'your age is', age
In one sentence, convert a Linq statement to an SQL statement.Zookeeper
Public IEnumerable {IEnumerable IQueryable MerchantList = Report_List ();
# Region obtain the VMB_Report set from MerchantList
ResultModel = merchantList. Select (o => new VMB_Report{
MerchantID = o. MerchantID,MID = o. MID,DBA = o. DBA,DBAPhone = o. DBAPhone,ContactName = o. ContactName,TotalSalesYTD = o. MerchantVolume. TotalSalesYTD,BankcardAvgTicketYTD = o. MerchantVolume. Ban
Conditions test statement and Shell condition test statement in Shell
Shell has conditional test statements. Generally, the test or [] commands are used to complete the test. They are conditional judgment statements if ~ The basis of the then statement, especially the [] command. The following describes some conditional test statements.
1. test command to imp
Mssql returns the table creation statement. mssql returns the creation statement.
If OBJECT_ID ('SP _ create_table_ SQL ', 'P') is not nullddrop proc sp_create_table_sqlgocreate proc sp_create_table_ SQL (@ tablename varchar (255 )) as begin -- exec sp_create_table_ SQL 'ad _ adgroup' -- 0. hong En-1. indexes of non-primary key classes are not supported -- 2. non-default sorting of the primary/secondary key
Placeholder for select statement, select statement
For prepared statements, you can use a location toggle. The following statement returns a row from the tb1 table:
Mysql>SET @ a = 1;
Mysql>Prepare stmt from "SELECT * FROM tbl LIMIT? ";
Mysql>Execute stmt using @;
The following statement returns the second to sixt
With statement
Execute a series of statements on an object.
With objectstatementsEnd WithParameters
Object
Required. It can be an object name or a function whose return value is an object.
Statements
Required. To pairObjectOne or more commands.Description
WithA statement can be used to execute a series of statements on a specified object, but the object name does not need to be repeated. For example, if you
Find the corresponding SQL statement using the PID in the operating system, and find the SQL statement using the pid.In linux, we generally use the TOP command to view the processes with the largest performance consumption. If oracle is used, we need to query the SQL statements currently executed by the process through the process number, baidu has a lot of SQL statements on the Internet. I usually search t
1 Data _ NULL; /* _ Null _ makes it unnecessary for the system to generate a new dataset to save memory. */ 2 Infile ' C: \ myrawdata \ candy. dat ' ; 3 Input name $ 1 - 11 Class @ 15 Datereturned mmddyy10. candytype $ quantity; 4 Profit = Quantity * 1.25 ; 5 6 /* Focus: output reports using file and put */ 7 File ' C: \ myrawdata \ student.txt ' Print;/* The file statement specifies the output path of the reprot. The print optio
ReDim statement
Declare dynamic array variables at the procedure level and allocate or reallocate storage space.
ReDim [Preserve] varname(subscripts) [, varname(subscripts)] . . .
Parameters
Preserve
Preserves data when changing the size of the last dimension of an existing array.
VarName
Variable names, followed by standard variable naming conventions.
subscripts
The number of dimensions of an array variable that can declare up to 60 dimensional arra
The shell can use "[]" to judge data, and "[]" is basically consistent with test.
When using "[]" pay attention to three points (from Brother Bird):
1, in the brackets "[]" in each component needs to have the space bar to split.
2, in the brackets inside the variables, preferably in double quotes around.
3. Constants in brackets, preferably enclosed in single or double quotes
The structure of the IF Else statement is:
if [condition]; Then
#some statem
values (1, ' ltx '); You can also insert multiple columns of values into the table, such as INSERT INTO Test (' Ltx '), (' Hhy '), (' XF '); Delete Records in table: Delete from test;//deletes all records in the table, delete from test where id=1;//deletes records in the table under specific conditions; When you want to query some fields from a table or multiple tables and then insert them into another table, you can use the Insert ... select syntax; insert into TESTT (name) (select name from
1 //Exception statement: try...catch...finally2 //Try : whether there is an error in the attempt3 //catch: Executes immediately if there are errors found in the try4 //finally: Regardless of the previous error, will be executed5Console.Write ("Please enter an integer:");6 Try7 {8 intA =int. Parse (Console.ReadLine ());9Console.WriteLine ("no problem with the program");T
Date formatting statement and SQL Server statement during SQL Server Query
The default datetime format of the Chinese version of SQL Server isyyyy-mm-dd Thh:mm:ss.mmm
For example:
select getdate() 2004-09-12 11:06:08.177
I sorted out the date format conversion methods that may be frequently used in SQL Server:
Example:
select CONVERT(varchar, getdate(), 120 ) 2004-09-12 11:06:08 select replace(replace(r
The SQL statement cyclically processes the data of the current row and the data of the previous row plus or minus, and the SQL statement
In the following example, we use a cursor to cycle the data in Table # temptable, and then add argument1 in the current row and the previous row to the argument2 in the current row, which is relatively simple.
--drop table #temptablecreate table #temptable( argument1 int,
SQL statement, mysql database, SQL statement mysql
SQL statement to insert data in one table and specific data (fixed constants) into another table
insert into wm_jobpoint_allstatus(CODE,pointstatus,housestatus,roomstatus,workstatus) select code,0,1,1,1 from wm_jobpoint
INSERT INTO wm_department(departmentcode,departmentname,provincecode,citycode,countycode,longi
PHP constructs an SQL statement instance and an SQL statement instance.
This example describes how to construct an SQL statement class implemented by PHP. We will share this with you for your reference. The details are as follows:
/*** @package Database Class* @author injection (mail:injection.mail@gmail.com)* @version 1.0*/@ini_set( 'display_errors',0 );class Da
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.