Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save paulobunga/27940dd8ee2fbf2e570aa65e6e565fbd to your computer and use it in GitHub Desktop.
Save paulobunga/27940dd8ee2fbf2e570aa65e6e565fbd to your computer and use it in GitHub Desktop.
MySQL Trigger to insert distinct values while checking existing in new table

INSERT INTO locations(dhis_id, facility_name, location) SELECT DISTINCT dhis_id, facility_name, location FROM dhis_count WHERE dhis_id NOT IN(SELECT dhis_id FROM locations)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment