Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Capital letters are a lesser value than lower case in SQL
- filter first, then sort
- SQL
- SELECT *
- FROM recipes
- WHERE chef = 'Rachel Ray';
- Rails => Recipe.where("chef = ?", "Rachel Ray")
- SELECT *
- FROM recipes
- ORDER by chef DESC;
- Rails => Recipe.all.order(chef: :desc)
- SELECT *
- FROM recipes
- ORDER BY id
- LIST 1;
- Rails => Recipe.first
- SELECT *
- FROM recipes
- ORDER BY id DESC
- LIST 1;
- Rails => Recipe.last
- look up XKCD comics
- .where returns a collection
- .all returns an array
- sanitize => use ?
- ? protects data base - always use
- ex: Recipe.where("title iLIKE ?", query)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement