Grow your CSS skills. Land your dream job.

SQL Like Statement in WordPress

  • # January 31, 2013 at 11:11 am

    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.

    # January 31, 2013 at 11:25 am

    It would look similar to this.

    $wpdb->prepare( “SELECT COUNT(post_author) from wp_posts WHERE post_title NOT LIKE %s;”, ‘%’ . like_escape($ReplyTo) . ‘%’);

    # January 31, 2013 at 11:32 am

    thanks @TylerNYC but i doesn’t work :(

    # January 31, 2013 at 11:37 am

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

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".