How to UNION Craft blog articles array with Social Media plugin (non craft table) I'm looking for a way to merge blog article entries with social media entries (non craft table). The idea is to output both entry types together from the same array, this will allow me to order all entries by date.

The social media plugin that I have put together queries the non-craft social media table but I need a solution to UNION the two tables together.

How would I go about doing this within Craft?

My table structure for craft_archived_social_items


id int  
unique_id varchar(255) NOT NULL,
account varchar(255) NOT NULL,
category varchar(255) NOT NULL,  
title text NOT NULL,
content text NOT NULL,
image varchar(255) NOT NULL,
link text NOT NULL,
date datetime NOT NULL,
status varchar(255) NOT NULL DEFAULT 'inactive',
date_cached datetime NOT NULL,

PRIMARY KEY (id)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=1;


My service file is currently using the db-&gt;createCommand to query the table

    $social_items = craft()-&gt;db-&gt;createCommand()
        -&gt;select('title, content, date, category, id, account, unique_id, image, link')
        -&gt;from('archived_social_items') 
        -&gt;offset($offset)
        -&gt;limit($counter)
        -&gt;order('date desc')
        -&gt;queryAll();
More of general guidance than an answer, but I'd look into creating a custom ElementType and overriding the modifyElementsQuery in your ElementType to latch onto the main query Craft uses to grab elements.  From there you'd be able to join in whatever other data you need.