我有一個問題,在同一查詢中向不同的表獲取4個SQL請求。查詢是:將小查詢合併爲一個較大的mysql查詢
SELECT COUNT(*) AS posts FROM `wp_posts` WHERE post_type='updates' AND post_status='publish'
而且
SELECT COUNT(*) AS posts FROM `wp_posts` WHERE post_type='post' AND post_status='publish'
的wp_posts
表結構是:
| ID | title | post_type | post_status |
------------------------------------------------
| 1 | Name | updates | publish |
| 2 | Name 2 | post | publish |
其他請求:
SELECT COUNT(*) AS users FROM wp_usermeta WHERE wp_usermeta.meta_value LIKE '%delegate%'
wp_usermeta
的表結構我S:
| ID | user_id | meta_key | meta_value |
-----------------------------------------------------------------
| 29 | 4 | ei_capabilities | a:1:{s:13:"delegate";b:1;} |
,最後一個:
SELECT wp_postmeta.meta_value AS version FROM wp_postmeta WHERE wp_postmeta.meta_key='content_version' AND post_id=1
wp_postmeta
表結構是:
| ID | post_id | title | meta_key | meta_value |
---------------------------------------------------------------
| 21 | 1 | Name | content_version | 1 |
有沒有辦法將它們組合成一個要求嗎?
一個rwquest手段?作爲一個查詢? –
嗨@SubinCPoonamgode是隻是在一個SELECT – qqruza
pls添加表結構,或者我們可以加入這兩個表之間的字段(如果存在的話) – user3600910