[PHP-DB] distinct - how to do

2002-01-19 Thread Barry Rumsey

I have the following query:
$query = SELECT  * FROM xp_topics, xp_stories WHERE xp_topics.topicid = 
xp_stories.topicid AND xp_topics.artistname='Faith Hill' ORDER BY topictext DESC LIMIT 
0,20; 
It returns the lot but a lot of doubles.
 I want to put a DISTINCT call the query, but if I put it after the select ( select 
distinct * from...) it returns nothing. How do you do a DISTINCT?



Re: [PHP-DB] distinct - how to do

2002-01-19 Thread Paul DuBois

At 2:28 +1300 1/20/02, Barry Rumsey wrote:
I have the following query:
$query = SELECT  * FROM xp_topics, xp_stories WHERE 
xp_topics.topicid = xp_stories.topicid AND 
xp_topics.artistname='Faith Hill' ORDER BY topictext DESC LIMIT 
0,20;
It returns the lot but a lot of doubles.
  I want to put a DISTINCT call the query, but if I put it after the 
select ( select distinct * from...) it returns nothing. How do 
you do a DISTINCT?

That's how you do it (add DISTINCT after the SELECT keyword).
You must be doing something else wrong.

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] distinct - how to do

2002-01-19 Thread Miles Thompson

Barry,

Change --  xp_topics.topicid = xp_stories.topicid
to--- xp_stories.topicid = xp_topics.topicid
and see what your results are. Your primary selection is on xp_topics.

Then add DISTINCT following your SELECT.

That should do the trick - Miles

At 02:28 AM 1/20/2002 +1300, Barry Rumsey wrote:
I have the following query:
$query = SELECT  * FROM xp_topics, xp_stories WHERE xp_topics.topicid = 
xp_stories.topicid AND xp_topics.artistname='Faith Hill' ORDER BY 
topictext DESC LIMIT 0,20;
It returns the lot but a lot of doubles.
  I want to put a DISTINCT call the query, but if I put it after the 
 select ( select distinct * from...) it returns nothing. How do you do 
 a DISTINCT?


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]