Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
How To Filter Out Duplications in the Returning Rows
How To Filter Out Duplications in the Returning Rows? - MySQL FAQs - SQL SELECT Query Statements with GROUP BY
✍: FYIcenter.com
If there are duplications in the returning rows, and you want to remove the duplications, you can use the keyword DISTINCT in the SELECT clause. The DISTINCT applies to the combination of all data fields specified in the SELECT clause. The tutorial exercise below shows you how DISTINCT works:
mysql> CREATE TABLE fyi_team (first_name VARCHAR(8), last_name VARCHAR(8)); mysql> INSERT INTO fyi_team VALUES ('John', 'Gate'); mysql> INSERT INTO fyi_team VALUES ('John', 'Russell'); mysql> INSERT INTO fyi_team VALUES ('John', 'Seo'); mysql> INSERT INTO fyi_team VALUES ('John', 'Gate'); mysql> INSERT INTO fyi_team VALUES ('James', 'Gate'); mysql> INSERT INTO fyi_team VALUES ('Peter', 'Gate'); mysql> INSERT INTO fyi_team VALUES ('John', 'Gate'); mysql> SELECT * FROM fyi_team; +------------+-----------+ | first_name | last_name | +------------+-----------+ | John | Gate | | John | Russell | | John | Seo | | John | Gate | | James | Gate | | Peter | Gate | | John | Gate | | John | Gate | +------------+-----------+ 8 rows in set (0.00 sec) mysql> SELECT DISTINCT * FROM fyi_team; +------------+-----------+ | first_name | last_name | +------------+-----------+ | John | Gate | | John | Russell | | John | Seo | | James | Gate | | Peter | Gate | +------------+-----------+ 5 rows in set (0.00 sec) mysql> SELECT DISTINCT last_name FROM fyi_team; +-----------+ | last_name | +-----------+ | Gate | | Russell | | Seo | +-----------+ 3 rows in set (0.04 sec)
2007-05-11, 4709👍, 0💬
Popular Posts:
How To Control Padding Spaces within a Table Cell? - XHTML 1.0 Tutorials - Understanding Tables and ...
How to create a thread in a program? You have two ways to do so. First, making your class "extends" ...
How do you handle change request? Normally change request are handled by preparing an Impact analysi...
Are risk constant through out the project ? * Never say that risk is high through out the project. R...
Do events have return type ? No, events do not have return type.