php - Fetching results from different tables with the same structure -
i'm being asked if can fetch result 18 different wordpress databases merged 1 database with conflicting names, filter them, , play results in php.
for example:
i have data (posts) in ara_posts, val_posts, , car_posts (all of them tables have post_name, post_type, post_status , post_date in column names). want select data tables , filter result (only show results have post_type = 'post').
what want result compare dates , fetch latest 3 posts 18 tables, have status "publish" , post type "post".
how possible?
as proposed in answer this question quite similar yours, can use union operator. this:
(select post_name, post_type, post_status, post_date ara_posts post_status='publish' , post_type='post') union (select post_name, post_type, post_status, post_date val_posts post_status='publish' , post_type='post') union (...) order post_date desc limit 3
Comments
Post a Comment