Today, due to work needs, we need to find different record values under a certain field in the database. The very simple problem is too complicated and depressing, the reason is that a command of SQL has been forgotten, and the problem has been solved. Please forget it as soon as possible.
In fact, you only need to use the DISTINCT command in SQL. The syntax is as follows:
Copy codeThe Code is as follows: select distinct column name FROM Table Name
Example:
Suppose there is a database table: htmer:
Copy codeThe Code is as follows:
Field001
Record 1
Record 2
Record 1
Record 3
Now there are four records in this table, but one record is repeated. If I want to remove this record, only the SQL statements that do not repeat the record are listed as follows:
Copy codeThe Code is as follows: select distinct field001 FROM htmer
The result is as follows:
Copy codeThe Code is as follows:
Field001
Record 1
Record 2
Record 3