• Hi could someone please validate my SQL. I can’t find a problem but it clearly isn’t working.

    “SELECT * FROM $tableposts
    WHERE post_date <= ‘$now’
    AND post_status = ‘publish’
    AND ID = (
    SELECT post_id FROM wp_postmeta
    WHERE meta_value = ‘$key’)”

    Cheers,
    S.

Viewing 3 replies - 1 through 3 (of 3 total)
  • If you’re using an older version of MySQL (i.e. 3.2.3, which a lot of web hosts are still running) then you can’t use subqueries.

    You don’t need a subquery here. The following should work, though it’s done freehand and might have a typo:

    SELECT $tablesposts.* FROM $tableposts, $tablepostmeta
    WHERE post_date <= ‘$now’
    AND post_status = ‘publish’
    AND ID = post_id and
    meta_value = ‘$key’

    Thread Starter drzax

    (@drzax)

    Cheers, guys. All sorted.

    S.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Validate my SQL?’ is closed to new replies.