I. use the SELECT clause to perform multi-table query the SELECT field name FROM Table 1, table 2WHERE Table 1 field Table 2 field AND other query conditions SELECTaid, aname, aaddress, adate, bmath, benglish, bchineseFROMtb_demo0
I. use the SELECT
This article mainly introduces the comparison and usage of distinct and groupby in MySQL. There are many similarities between the two in query operations, if you need a friend, you can refer to the bibliography recorded in the data table for user
For example, there are 2 fields in the table, one name, one score.
1.name=张三 fs=87.52.name=张三 fs=703.name=李四 fs=854.name=李四 fs=90
I want to count a ranking now, likeThe total score of "Zhang San" is 87.5+70=157.5The total score of "John Doe" is 85+9
Method 1
Declare @ Max integer, @ ID integerDeclare cur_rows cursor local for Select Main field, count (*) from table name group by main field having count (*)> 1Open cur_rowsFetch cur_rows into @ ID, @ MaxWhile @
Test
Name Add num
A WEFSV 3
B asdf 4
b wers 9
b w1rs 10
As ASDF 11
As Wers 12
As W3rs 13
For example the above table, I need to use SELECT * from Test ...
To select the following results (the largest of num in each name, as long as one
MySQL reports error 1093, mysql reports error 1093
[Err] 1093-You can't specify target table 'user' for update in FROM clause
The error SQL statement is as follows:
Delete from 'user' where id not in (select min (id) as id from 'user' group by
The following code is used to generate a table instance in PHP, which is post after the program home test runs normally on this site.
$ Link = mysql_connect ("localhost", "root", "123456 ");
$ Db = mysql_select_db ("bustest", $ link );
$ Sql1 =
MySQL deduplication is a common operation. The following describes several common methods for deleting duplicate records in MySQL. If you have encountered any problems in deleting duplicate records in MySQL, take a look.
When using mysql, you
A pivot table is a method for analyzing data. It contains a powerful data pivot function in Excel. What is data pivoting? It may be easier to give an example. Assume there is a data table:
Sales volume of books
---------------------------------------
Database Theory 1. What does a trigger do? A trigger is a special stored procedure that is executed primarily by triggering an event. It can enforce constraints to maintain the integrity and consistency of data, and can track operations within the
Introduction to SQL subquery Examples:
A subquery is a query within a query. The results of the subquery are used by the DBMS to determine the results of the advanced query that contains this subquery. In the simplest form of a subquery, the
(i) a single field
1, look up the redundant records in the table, according to (Question_title) field to judge
The code is as follows
SELECT * from questions where Question_title in (select Question_title to
This article has shared two examples of row-and-column horizontal display of SQL query statements for your reference, the following details
Example 1:
There is no case in Access for SQL query statement row-column horizontal display, use IIF
Bulk Delete Multiple tables
Delete all pre_ prefixes table
The code is as follows
Copy Code
SELECT CONCAT (' drop table ', TABLE_NAME, '; ') from Information_schema.tables whereInformation_schema.tables.TABLE_NAME like '
, and can not return to other fields, this problem let me worry for a long time, with the distinct can not be resolved, I only use the double loop query to solve, and so for a very large amount of data station, it will undoubtedly directly affect
SQL Delete duplicate dataThis article provides a MySQL delete duplicate data, is the data table there are more than two duplicate data, delete the smallest number of a piece of information.Delete ' Borough_name ' as a from Fke_borough as a,(Select *,
SQL statements for querying and deleting duplicate records
ASayThere is a field "name" in Table A,and the "name" value may be the same between different records,Now you need to query the records in the table, the "name" value duplicates the item;
Method 1 Delete yourtable where [id] not in ( Select MAX ([id]) from yourtable Group by (name + Valu) E) Method 2 Delete a from table a LEFT join ( Select (ID) from table GROUP by Name,value ) b on A.id=b.id Where b.id is null Query and
Description: Copy table (copy only structure, source table name: A new table name: b)SELECT * into B from a where 1<>1
Description: Copy table (copy data, source table name: A target table name: b)Insert into B (A, B, c) select d,e,f from B;
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.