SHARE
TWEET

Untitled

a guest Sep 17th, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Capital letters are a lesser value than lower case in SQL
  2.  
  3. filter first, then sort
  4.  
  5. SQL
  6.  
  7. SELECT *
  8. FROM recipes
  9. WHERE chef = 'Rachel Ray';
  10.  
  11. Rails => Recipe.where("chef = ?", "Rachel Ray")
  12.  
  13. SELECT *
  14. FROM recipes
  15. ORDER by chef DESC;
  16.  
  17. Rails => Recipe.all.order(chef: :desc)
  18.  
  19. SELECT *
  20. FROM recipes
  21. ORDER BY id
  22. LIST 1;
  23.  
  24. Rails => Recipe.first
  25.  
  26. SELECT *
  27. FROM recipes
  28. ORDER BY id DESC
  29. LIST 1;
  30.  
  31. Rails => Recipe.last
  32.  
  33. look up XKCD comics
  34.  
  35. .where returns a collection
  36. .all returns an array
  37.  
  38. sanitize => use ?
  39. ? protects data base - always use
  40. ex: Recipe.where("title iLIKE ?", query)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top