此查询有效.. 一次查询 50 个 mysql 数据库并返回最近的 10 个结果,但是.. 有没有办法不查询每个状态的整个数据库(我的示例中仅列出 4 个状态),只需获取顶部10(按timeStamp desc)并使此查询更有效率?
$query = "
SELECT imgURLThumb, timeStamp, title2, state, postId, title
FROM (
SELECT imgURLThumb,timeStamp, title2, state, postId, title FROM db_washington.md_postings UNION ALL
SELECT imgURLThumb,timeStamp, title2, state, postId, title FROM db_westvirginia.md_postings UNION ALL
SELECT imgURLThumb,timeStamp, title2, state, postId, title FROM db_wisconsin.md_postings UNION ALL
SELECT imgURLThumb,timeStamp, title2, state, postId, title FROM db_wyoming.md_postings
) allposts where imgURLThumb <> 'images/nopicture.png' order by timeStamp DESC LIMIT 0 , 10";