distinct query 
Author Message
 distinct query

can anyone tel me why i get  results of the same employee even when i
write "distinct":

SELECT DISTINCT *
FROM Employees, employee_fields, fields
WHERE fields.field_id= employee_fields.field_id and
employees.employee_number=employee_fields.employee_number

and (Employee_fields.Field_id = 51 or Head_Field_id=51 or
Senior_Field_id=51);

(the first rows are the join. the last 2 are the condition)

*** Sent via Developersdex http://www.*-*-*.com/ ***
Don't just participate in USENET...get rewarded for it!



Wed, 16 Jun 2004 09:07:39 GMT  
 distinct query
Using the '*' character you are receiving the distinct everything, which
does not really make anything distinct. Replace the '*' character with
your field names you want to return instead eg.
SELECT DISTINCT Employee, EmployeeAddress, EmployeePhone etc
Cheers
Dave
Quote:

> can anyone tel me why i get  results of the same employee even when i
> write "distinct":

> SELECT DISTINCT *
> FROM Employees, employee_fields, fields
> WHERE fields.field_id= employee_fields.field_id and
> employees.employee_number=employee_fields.employee_number

> and (Employee_fields.Field_id = 51 or Head_Field_id=51 or
> Senior_Field_id=51);

> (the first rows are the join. the last 2 are the condition)

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Wed, 16 Jun 2004 15:06:45 GMT  
 distinct query
DISTINCT instruct SQL server to eliminate the duplicate
rows from the resultset and to include only one copy of
such rows. Since you select all the columns from 3 tables
it's very likely that there are columns with different
values in the resultset even though the employee_number
for example is the same. If even only one column has
different value the rows will be considered different.

Vladimir

Quote:
>-----Original Message-----

>can anyone tel me why i get  results of the same employee
even when i
>write "distinct":

>SELECT DISTINCT *
>FROM Employees, employee_fields, fields
>WHERE fields.field_id= employee_fields.field_id and
>employees.employee_number=employee_fields.employee_number

>and (Employee_fields.Field_id = 51 or Head_Field_id=51 or
>Senior_Field_id=51);

>(the first rows are the join. the last 2 are the
condition)

>*** Sent via Developersdex http://www.developersdex.com
***
>Don't just participate in USENET...get rewarded for it!
>.



Wed, 16 Jun 2004 14:20:32 GMT  
 distinct query

Hi Vladimir

I understand and you are right, but do you know how can I solve it?

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Wed, 16 Jun 2004 22:55:37 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Problem with Memo field in SELECT DISTINCT queries

2. Distinct query question?

3. Distinct Query with ADOCE

4. Distinct Corporation's ICMP control and WINS query

5. Distinct Corporation's ICMP control and WINS query

6. difference between DISTINCT and DISTINCTROW (in a SQL query)

7. DISTINCT and DISTINCTROW in a SQL query?

8. Not Distinct SQL Query

9. Recordset error using DISTINCT in MSSQL7 query

10. Distinct Clause in SQL Query

11. how can I build 2 queries in 1 query(VB SQL query)

12. Distinct Count on a Field?

 

 
Powered by phpBB® Forum Software