Page 1 of 1

Select non matching rows

Posted: Fri Oct 15, 2010 6:07 pm
by echofool
Hey,


How do you do a query that selects non matching rows from a single table by camparing values in one field.

Say two rows had:
FieldName : 5
FieldName : 4

This in a query should be noticed and selected as the two rows have different field values.

Any idea how this is done?

Re: Select non matching rows

Posted: Sun Oct 17, 2010 5:00 pm
by DigitalMind
If I got you right:

Code: Select all

select distinct fieldname from yourtable

Re: Select non matching rows

Posted: Sun Oct 17, 2010 5:04 pm
by John Cartwright
otherwise... GROUP BY fieldname

Re: Select non matching rows

Posted: Mon Oct 18, 2010 4:03 pm
by VladSun
I vote for using DISTINCT.
Using GROUP BY clause just to achieve the DISTINCT functionality should be considered a bad practice.