Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

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

Select an option

Save worstn8mare/cca91f80ad680b485fd14536e49f6507 to your computer and use it in GitHub Desktop.
INSERT INTO postings (id,cb,partner_id,post_date,posting_type,status,doc_type,doc_no,attachment_no)
(
SELECT
a.posting_id as id,
a.cb as cb,
a.partner_id as partner_id,
c.date as date,
"Purchases" as posting_type,
"Posted" as status,
"RR" as doc_type,
a.doc_no as doc_no,
c.id as attachment_no
from gl_entries as a
LEFT JOIN receive_headers as b on b.id = a.doc_no
LEFT JOIN receive_post_details as c on c.rr_id = b.id
where a.doc_type = "RR" and a.doc_no = 20283 and b.status in ("Approved","Printed")
limit 1
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment