Re: Query returns duplicate rows

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

 



On Wed, 21 Jul 2004 16:29:37 -0400, Brock Jimmy D Contr 74 MDSS/SGSI
<jimmy.brock@xxxxxxxxxxxx> 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?
> 

Should you perhaps be doing some kind of ON clause to that join? It's
joining every record in elements with every element in scores. You
need to tell it what fields to join on.

Also, doing a distinct on that many fields at once could be very
expensive. Better tp refine your query or data model.

-- 
DB_DataObject_FormBuilder - The database at your fingertips
http://pear.php.net/package/DB_DataObject_FormBuilder

paperCrane --Justin Patrin--

-- 
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