任何人可以幫助我得到的結果形式多個SQL請求:綁定多個查詢到一個結果
SELECT *
(COUNT(*) AS Records FROM wp_posts WHERE post_type='news' AND post_status='publish') as News,
(COUNT(*) AS Records FROM wp_posts WHERE post_type='promotion' AND post_status='publish') as Promos,
(COUNT(*) AS Records FROM wp_posts WHERE post_type='contact' AND post_status='publish') as Contacts
FROM wp_posts
我只是想通過發送一個SQL請求,找出定製我的WP MySQL的多少職位。
這個人是一個好方法! +1 –
也許計數(CASE WHEN post_type ='news'THEN 1 END)稍快些? – jarlh
@jarlh好吧,我不喜歡隱式的NULL,我會說這是味道的問題 – lad2025