I have this SQL query here:
SELECT wp_posts.*, wp_postmeta.* FROM wp_posts, wp_postmeta WHERE wp_posts.ID=wp_postmeta.post_id AND meta_key='image_path' group by ID desc
however I would like to get the count total from this how can I do it?
I have this SQL query here:
SELECT wp_posts.*, wp_postmeta.* FROM wp_posts, wp_postmeta WHERE wp_posts.ID=wp_postmeta.post_id AND meta_key='image_path' group by ID desc
however I would like to get the count total from this how can I do it?
what exactly is it that you want to count?
what table does the ID in your GROUP BY clause belong to?
I want to count the number of times the query finds a match from both tables, the ID I’m talking about is from wp_posts.ID
do you want the count for each ID, or the total count overall?
the total count for each ID
SELECT post_id
, COUNT(*)
FROM wp_postmeta
WHERE meta_key = 'image_path'
GROUP
BY post_id DESC
actually it didn’t give the proper result I was looking for can you please show me the query for the total count overall?
thanks
SELECT COUNT(*)
FROM wp_postmeta
WHERE meta_key = 'image_path'