Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save worstn8mare/fdd2d074d19478f9ccfed51a73c5d5fd to your computer and use it in GitHub Desktop.

Select an option

Save worstn8mare/fdd2d074d19478f9ccfed51a73c5d5fd to your computer and use it in GitHub Desktop.
$posted = DB::select("
SELECT
a.id,
(
SELECT COUNT(*) FROM
pc_attachment_files as c
WHERE c.detail_id = b.id
) as attachment_file_count
FROM
pc_headers as a
LEFT JOIN pc_details as b on a.id = b.header_id
WHERE
(b.attachment_file = ''
OR b.attachment_file is null)
and
a.id = ?
",[$id]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment