• Resolved Biswadip

    (@biswadip)


    I am trying to write a MYSQL query to pull some bbpress forums data out of my wp_posts table. As long as there is one condition like:

    $query=”SELECT * FROM wp_posts WHERE post_type = ‘forum’;

    it works fine but when there is more than one condition like:

    $query=”SELECT * FROM wp_posts WHERE post_type = ‘forum’ AND post_title = ‘Business Intelligence'”;

    it returns nothing! When I paste the same query in the PHPmyadmin editor on the same table it returns the right result.

    Thanks for your help

    Bis

Viewing 3 replies - 1 through 3 (of 3 total)
  • With the information you’ve given, the query

    SELECT * FROM wp_posts WHERE post_type = 'forum' AND post_title = 'Business Intelligence';

    looks perfectly valid.

    I’m going to ask the obvious. Are you certain that PHPMyAdmin and your script are connected to the same database?

    Also, do you get the same exact results when you use the simpler query?

    SELECT * FROM wp_posts WHERE post_type = 'forum';

    Thread Starter Biswadip

    (@biswadip)

    Yes I made the obvious error of not checking if my script was connected to the same database!

    Thank you for taking the time to answer my question so promptly and helping me to correct my own oversight and sorry for wasting your time! Best 😉

    You’re quite welcome and no, not a waste of time at all. In fact, you benefited from my experience of doing the same exact thing a time or two in the past. Good luck and happy coding!

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘MySQL query not working with wp_posts table’ is closed to new replies.