Skip to content

Instantly share code, notes, and snippets.

@borkweb
Created October 28, 2013 19:15
Show Gist options
  • Save borkweb/7202819 to your computer and use it in GitHub Desktop.
Save borkweb/7202819 to your computer and use it in GitHub Desktop.
SQL Formatting in PHP
$sql = "
SELECT
p.ID AS id,
p.post_title AS name
FROM
$wpdb->posts p
LEFT JOIN $wpdb->postmeta pm ON
p.ID = pm.post_id
AND pm.meta_key = %s
WHERE
p.post_type = %s
AND p.post_status = %s
AND pm.meta_value IS NULL
ORDER BY
p.ID DESC
LIMIT %d
";
// and
$sql = "
SELECT p.ID AS id,
p.post_title AS name
FROM $wpdb->posts p
LEFT JOIN $wpdb->postmeta pm
ON p.ID = pm.post_id
AND pm.meta_key = %s
WHERE p.post_type = %s
AND p.post_status = %s
AND pm.meta_value IS NULL
ORDER BY p.ID DESC
LIMIT %d
";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment