Gossamer Forum
Quote Reply
SELECT DISTINCT
I have a problem with this:

Code:

my $cat_db = $DB->table ('Links','CatLinks','Category');
$cat_db->select_options ("ORDER BY ID ", "LIMIT 8");
my $sth = $cat_db->select (['Links.ID','Contact_Name','Logo','Ort','Name2'],
GT::SQL::Condition->new ('Logo','!=','',
'isValidated','=','Yes',
'visible','=','Yes'
) );


Because most of the links are in more than one category, i got no unique links with the query above.
The query now is: SELECT * FROM Links, CatLinks, Category WHERE ... but i need something like:
SELECT DISTINCT FROM Links, CatLinks, Category WHERE ...

Shurely i can use a query without a LIMIT and compare the IDs stoppting with a while counter=8;
but it should be with one query, i hope. Some ideas?
Quote Reply
Re: [Robert] SELECT DISTINCT In reply to
Seems i was wrong:

Code:

SELECT DISTINCT ( Links.ID ), Links.Contact_Name, Links.Logo, Links.Ort, Category.Name2
FROM CatLinks, Category, Links
WHERE CatLinks.LinkID = Links.ID
AND CatLinks.CategoryID = Category.ID
AND ( Logo != ''
AND isValidated = 'Yes'
AND visible = 'Yes'
)
ORDER BY ID
LIMIT 8


This query still pass no unique IDs; i could solve my problem with a "WHERE FatherID=0"; beacuse i have luckily every link in a maincat and the other cats are under the maincats. But i really would like to know how i can solve it in any other situation, too.
Quote Reply
Re: [Robert] SELECT DISTINCT In reply to
I'm really not sure what you are trying to do.

"distinct" is a really hairy concept to work with. You might try to seach on it to see what/why it may not be working.

It doesn't work the way you want it to.

Check this out: http://www.gossamer-threads.com/...orum.cgi?post=265352


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.