I will try and ask my question clearly…
I have three tables that each contain a date value. Node and Product have a “created on” date and Shared has a “timestamp” date. I need to figure out how to order by a single date… I need to merge both dates together…
it needs to fit in this statement
SELECT sc.auto_id AS autoid, sc.uid AS sharedby, n.nid, sc.message AS sharedmessage,
(
SELECT COUNT(1)
FROM {share_content} AS sc2
WHERE sc2.nid = sc.nid
) AS countnid
FROM {node} n LEFT JOIN {content_type_product} p on n.nid = p.nid
LEFT JOIN {share_content} sc on sc.auto_id=
(
SELECT MAX(auto_id) FROM share_content sc1
WHERE sc1.nid = n.nid
LIMIT 1
)
WHERE (
n.type = 'blog'
OR n.type = 'field_school'
OR n.type = 'photo_gallery'
OR n.type = 'forum'
OR n.type = 'product_review'
OR n.type = 'product' and p.field_front_page_value = 'Add to feed'
OR n.type = 'reference'
OR n.type = 'video_gallery'
OR n.type = 'video'
OR n.type = 'groups'
OR n.type = 'group_post'
OR n.type = 'status'
OR (n.type = 'event' AND n.uid != '2')
OR n.type = 'jobs_careers'
OR n.type = 'post_link'
OR (n.type = 'news_article' AND n.uid != '2' AND n.uid != '0'))
AND n.status = '1'
ORDER BY n.created DESC";
(order needs to be a merge between n.created, p.created and sc.date_shared)…
Thank you,
Matt
Horrifying!!!