• Resolved csseur3

    (@csseur3)


    Hello,

    this is my query:

    $test_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->postmeta WHERE meta_key LIKE '%salon%'", $meta_key));

    I have many posts with meta_key “salon_irc” and “salon_jabber”, so, my query count only the posts with “salon_jabber” meta_key ?? why?

    bye

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi csseur3,

    Can you tell me how you resolved this?
    I’ve got the same sort of problem. :-/

    Thanks.

    Frank

    Thread Starter csseur3

    (@csseur3)

    $stat_all_chat = $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->posts a WHERE EXISTS (SELECT meta_id FROM $wpdb->postmeta WHERE post_id = a.ID AND meta_key in ( ‘salon_irc’, ‘salon_jabber’))”);

    ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Count posts with meta_key LIKE’ is closed to new replies.