Skip to content

Instantly share code, notes, and snippets.

@Geoffrey-T
Forked from nicolasramy/mysql-cs-01-introduction.md
Created March 4, 2013 16:10
Show Gist options
  • Select an option

  • Save Geoffrey-T/5083337 to your computer and use it in GitHub Desktop.

Select an option

Save Geoffrey-T/5083337 to your computer and use it in GitHub Desktop.

MySQL

Databases

Tables

Create

Create ... Select

CREATE TABLE tableName SELECT ...

Delete

DELETE FROM tableName WHERE tableName.fieldName1 = condition1 AND tableName.fieldName2 = condition2

Delete ... Join

DELETE t1,t2 FROM t1,t2,t3 WHERE t1.id=t2.id AND t2.id=t3.id

or

DELETE FROM t1,t2 USING t1,t2,t3 WHERE t1.id=t2.id AND t2.id=t3.id

OR

DELETE tab1, tab2 FROM tab1 INNER JOIN tab2 WHERE tab1.id = tab2.parent_id AND tab2.value > 3;

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