Mysql series-basic knowledge, mysql-Basic Knowledge
Note: This article summarizes the basic knowledge of mysql. If there are many basic points, please search for them by yourself. Continuous update
I. mysql Introduction
Database Introduction
A
For example, there is a personnel table (table name: peosons)If you want to query records whose names, ID card numbers, and addresses are identical
Select p1. * from persons p1, persons p2 where p1.id <> p2.id and p1.cardid = p2.cardid and p1.pname =
When using MySQL, there are times when you need to query for records that are not duplicated in a field, although MySQL provides a distinct keyword to filter out excess duplicates, but it often only uses it to return the number of records that are
Each record has a hash field, the hash is the record of several different fields to form a unique value of the hash algorithm to save a value, with this hash, you can determine whether the record is duplicated, the SQL statement is as follows:
1, look for redundant records in the table, duplicate records are based on a single field (Peopleid) to judge
Copy Code code as follows:
SELECT * from People
where Peopleid in (select Peopleid from People GROUP by Peopleid has count
(a) 1, find redundant records in the table, duplicate records are based on a single field (Peopleid) to determine the Select * from people where Peopleid in (select Peopleid from PEO PLE GROUP BY Peopleid have count (Peopleid) > 1) 2, delete
SQL statement Query method for database duplicate records SQL statement query database duplicate record method SQL statement query database record SQL statement query database duplicate record
Suppose you have an existing list of people (table name:
Excerpt from: https://www.cnblogs.com/wangzhuxing/p/7727713.htmlSQL Duplicate record query1, look for redundant records in the table, duplicate records are based on a single field (Peopleid) to determineSELECT * from Peoplewhere Peopleid in (select
When using MySQL, there are times when you need to query for records that are not duplicated in a field, although MySQL provides a distinct keyword to filter out excess duplicates, but it often only uses it to return the number of records that are
Business requirementsRecently made a small tool for the company to bring data from one database (data source) into another (target database). The data required to import the target database cannot be duplicated. But the situation is that the data
Recent business Feedback A query exception problem requires the DBA to interpret the query result exceptions and help them resolve the problem. The problem essence is the problem of sorting the maximum within a group, and I built the test case
A1, look for redundant records in the table, duplicate records are based on a single field (Peopleid) to determineSELECT * from Peoplewhere Peopleid in (select Peopleid from People GROUP by Peopleid have count (Peopleid) > 1)Example two:SELECT *
Command line Operation SQLiteCreate a tableCREATE TABLE table name (Field Name field type, field Name field type);CREATE TABLE info (ID int,name varchar (20));Increase:Insert into table name values (value to add ...);When the data type of the field
Pivot is used to rotate column values to column names (row to column)Grammar:Table_sourcepivot (Aggregation function (value_column) for Pivot_columnin ())Unpivot used to set the column value to a column (that is, a column
First, prepare the test tableCREATE TABLE ' ts ' (' ID ' INT (one) not NULL auto_increment,' Name ' VARCHAR (() DEFAULT NULL,' Age ' INT (one) DEFAULT NULL,' Sex ' VARCHAR () DEFAULT NULL,PRIMARY KEY (' id ')) Engine=innodb auto_increment=1 DEFAULT
1. Add test data with stored proceduresCREATE PROCEDURE newprocedure ()BEGINDECLARE i INT;SET I=1;While iINSERT into User_new (id,name,phone,sex) VALUES (i,i,i,i);SET i = i + 1;END while;END;Two inserts, modifies the ID value of the stored procedure
SQL statement for querying and deleting duplicate records1, look for redundant records in the table, duplicate records are based on a single field (Peopleid) to determineSELECT * from Peoplewhere Peopleid in (select Peopleid from People GROUP by
The result set generated by Cube:cube shows aggregations for all combinations of values in the selected column.The result set generated by Rollup:rollup shows the aggregation of a hierarchy of values in the selected column.GROUPING: When a row is
Share the following method of deleting duplicate records in a database with an SQL statement.For example, there is now a person table (table name: peosons)If you want to name, ID, address, the three fields exactly the same record querySelect p1.*
Basic syntax: Group_concat ([DISTINCT] field to connect [order by sort field Asc/desc] [Separator ' delimiter '])Initial data: Group by name, print money on one line, default ', ' delimited:Select AA. ' Name ' name, Group_concat (money) money from
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.