Skip to content

Instantly share code, notes, and snippets.

@mdailey77
Created January 20, 2019 21:06
Show Gist options
  • Save mdailey77/e780dcbda02abb74a610a08a8dae983f to your computer and use it in GitHub Desktop.
Save mdailey77/e780dcbda02abb74a610a08a8dae983f to your computer and use it in GitHub Desktop.
A sampling of SQL scripts I wrote for a commericial web application
<?php
// inner join of multiple tables
"SELECT od.invoiceID, od.jobID, od.invoiceDate, o.datestamp, o.purchaseOrder, od.invoiceLineNumber, od.poLineNumber, od.itemICN, od.itemQuantity, od.itemPrice, od.itemName, od.salesTax, sh.shipToID, sh.company, sh.address1, "
. "sh.city, st.stateName, c.countryName, sh.zipCode, sh.email, od.salesTax FROM ordersdetail AS od INNER JOIN orders AS o ON od.jobID = o.jobID INNER JOIN shipTo AS sh ON o.shipToID = sh.shipToID"
. " INNER JOIN states AS st ON sh.stateID=st.stateID INNER JOIN countries AS c ON sh.countryID=c.countryID WHERE od.jobID=$jobID AND od.itemICN IN ($itemICNs) AND od.deleted=0 AND o.deleted=0";
// insert statement for adding a user
"INSERT INTO users (admintype, username, password ,userEmail, firstName, lastName, active, company1, address1, address2, city, stateID, zip, countryID)" .
"VALUES ('$admintype','$username','$password' ,'$userEmail', '$firstName', '$lastName', '$active', '$company1', '$address1', '$address2', '$city', '$stateID', '$zip', '$countryID')";
// update statement that updates multiple fields
"UPDATE ordersdetail SET invoiceID=$invoiceID, invoiceDate='$invoiceDate', invoiceLineNumber=$invoiceLineNmbr WHERE jobID=$jobID AND itemICN=$ICN AND deleted=0 AND orderSource='punchOut'";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment