Skip to content

Instantly share code, notes, and snippets.

@mbparvezme
Last active March 4, 2024 07:09
Show Gist options
  • Save mbparvezme/d861293c98808cabc47ee9a817936ab5 to your computer and use it in GitHub Desktop.
Save mbparvezme/d861293c98808cabc47ee9a817936ab5 to your computer and use it in GitHub Desktop.
// Copy-column.sql
UPDATE `table1` SET
`table1`.`col` = (SELECT `table2`.`col` FORM `table2` where `table1`.`ID` = `table2`.`fid`)
// REPLACE
UPDATE table SET col = REPLACE(col,',','')
// TRIM
UPDATE table SET col = TRIM(col);
// SUM with GROUP BY
SELECT col_1, SUM (col_2) FROM orders GROUP BY col_3;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment