Re: Query returns duplicate rows

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 22 Jul 2004 05:59, Brock Jimmy D Contr 74 Mdss/Sgsi wrote:

> My query is returning duplicates rows.
> 
> table: elements
> elementId
> standardId
> elementtext
> category
> mcode
> linenum
> 
> table: scores
> scoreId
> taskId
> scores
> 
> Here's my query:
> SELECT distinct elementtext,cateogy,mcode,linenum,scores,scoreId
> FROM elements, scores
> WHERE scores.taskId='12'
> AND elements.standardId='APR.05'
> 
> This is returning duplicate rows, even though I'm using the DISTINCT
> keyword.
> 
> If I remove the field scoreId it is fine.
> 
> Any suggestions?

I think you may misunderstand exactly what DISTINCT does. The keyword
applies to the entire record, not individal fields, and will effectively
delete any duplicate rows. ScoreId is presumably a unique ID for the
record; that being the case you can expect all selected rows will be
different.

Cheers
-- 
David Robley

Backups? We don' *NEED* no steenking backups.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux