English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

can I remove any duplicates from my query result
so if the query result is
123
123
123
456
456
456
789
789
789
I want my result to be
123
456
789

2006-06-18 03:37:01 · 2 answers · asked by barbarianseller 1 in Computers & Internet Programming & Design

2 answers

trying adding a distinct clause. Select (distinct) from... what's your query.

2006-06-18 03:39:06 · answer #1 · answered by ? 4 · 3 3

There is a KEYWORD from the standard SQL 03 standard and I believe before which is called DISTINCT.

If the result set contains the same row, then DISTINCT will filter them off.

Forexample in your query I am doing something similar.
SELECT numfield FROM numtable WHERE category=3
^ That might give you what you have above. Note I am just doing it , your schema representation wont be the same.

Now if I do this... SELECT DISTINCT numfield FROM numtable WHERE category=3
You will get those..
123
456
789

Remember and NOTE that You can have DISTINCT as in groups. So if you want to find the duplicates of 2 fields you could do DISTINCT(x,y).

Goodluck

2006-06-18 11:29:41 · answer #2 · answered by ? 6 · 0 0

fedest.com, questions and answers