[thelist] Need help with difficult MySQL query
Shashank Tripathi
sub at shanx.com
Fri Jul 12 20:32:11 CDT 2002
Simon,
It is not clear what you are trying to do. You want to return "one row
per entry", but also want all the categories to be listed out for each
entry that belongs to different queries? This is an implicit conflict in
those two criteria. If you only need "one row per entry", then what will
this row contain (do you want different categories of an entry to become
columns, if so, that is not possible of course)?
In any case, this is the closest you are going to get to your one row
need..
select distinct
entries.id
,entries.entryText
,entries.dateAdded
,categories.shortName
,categories.longName
from
entries
,categories
,ent_cat_lookup
where
entries.id = ent_cat_lookup.entryId
and categories.shortName = ent_cat_lookup.categoryShortName
group by entried.id
order by entries.dateAdded desc
limit 20
If this is not what you were looking for, please give a sample row from
'intended' results of the query..
I know I didn't help!
Shashank
More information about the thelist
mailing list