PDA

View Full Version : check out this query


AndrewSimm
03-10-2014, 12:38 AM
Currently it gets the catid from the entries and categories table. Problem is I want subcategories to show up on parent page. A column called parentlist which is in the categories table list both catid and parentid, so if it loaded entries based off the values in parentlist it should load the entries on the parent and child list. How would I do this?

$getentries = $db->query_read("
SELECT $condition[votequery] user.*, entries.entryid, entries.keywords, entries.title, entries.catid, entries.userid, entries.username, entries.views, entries.dateline, hasattach, entries.valid, draft, private, sticky, open, votenum, votetotal, entries.posts AS posts, caticon, customfields.* $queryfields
FROM " . ADV_DYNA_TABLE_PREFIX . "entries AS entries
LEFT JOIN " . ADV_DYNA_TABLE_PREFIX . "categories AS categories ON (entries.catid = categories.catid)
LEFT JOIN " . ADV_DYNA_TABLE_PREFIX . "cfields_entries AS customfields ON (entries.entryid = customfields.eid)
LEFT JOIN " . TABLE_PREFIX . "user AS user ON (entries.userid = user.userid)
$queryjoin
WHERE entries.entryid IN($entryids)
ORDER BY $condition[stickyorder] $condition[doorderby] $condition[direction]
" . iif($condition['doorderby'] != 'entries.dateline', ', entries.dateline ' . $condition['direction'])
);