treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] SQL Like Statement in Wordpress

  • i wrote following sql statement in mySQL and i got the answers i wanted without problems. but i wrote that in wordpress but no answers! i goggled and found out that you should use "like_escape()" in wordpress to for using "Like" SQL Statement! but the problem is i dont know how! here is my SQL that doesn't work in wordpress:

    "SELECT COUNT(post_author) FROM wp_posts WHERE post_title NOT LIKE 'Reply To:%' "

    any help will be appreciate.

  • It would look similar to this.

    $wpdb->prepare( "SELECT COUNT(post_author) from wp_posts WHERE post_title NOT LIKE %s;", '%' . like_escape($ReplyTo) . '%');

  • thanks @TylerNYC but i doesn't work :(

  • @TylerNYC i tried again your code and YEEES it Works! :) thanks @TylerNYC