Nested SELECT query

I didn’t know you could use a nested SELECT query until yesterday. All Thanks to Ms. Lucy Bilson, a colleague at the workplace. I am testing it right now and it is simply amazing! this is what I get:

Result of using a nested select query
select display_name from wp_users where id IN (
select post_author from wp_posts where id IN (
select object_id from wp_term_relationships where term_taxonomy_id IN (
select term_taxonomy_id from wp_term_taxonomy where term_taxonomy_id IN (
select term_id from wp_terms where name like "ABC"))))
order by id desc;

My task is to get the number of stories published by the authors/reporters of the newsroom I am currently employed with. The aim is to get the number of stories posted by a specific user from the database to display as a report. That is simple enough in itself, but the problem with the posts is that, the author has tagged a third party newsroom to give credit to that newsroom for the article he had used. Now

how can I get the stories the user had posted that are his own and not from the third party newsroom?

—more coming—


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s