Skip to content

Instantly share code, notes, and snippets.

@mikesimons
Created September 15, 2010 10:18
Show Gist options
  • Save mikesimons/580525 to your computer and use it in GitHub Desktop.
Save mikesimons/580525 to your computer and use it in GitHub Desktop.
QUERY: SELECT `people`.* FROM `people` WHERE (people.age < 20) AND (people.sex = "m")
RESULTS:
Name: baby joe bloggs
Age: 1
Sex: m
-------
QUERY: SELECT `people`.* FROM `people` WHERE (people.age < 20) AND (people.sex = "f")
RESULTS:
Name: baby joanna bloggs
Age: 1
Sex: f
-------
Name: joanna bloggs
Age: 17
Sex: f
-------
QUERY: SELECT `people`.* FROM `people`
INNER JOIN `documents` AS `d` ON d.people_id = people.id WHERE (people.sex = "m")
RESULTS:
Name: mike simons
Age: 25
Sex: m
-------
Name: joe bloggs
Age: 45
Sex: m
-------
Name: grandpa bloggs
Age: 72
Sex: m
-------
QUERY: SELECT `people`.* FROM `people`
INNER JOIN `documents` AS `d` ON d.people_id = people.id WHERE (people.sex = "m") AND (published > '2001-01-01 00:00:00') AND (published < '2005-12-31 23:59:59')
RESULTS:
Name: mike simons
Age: 25
Sex: m
-------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment