SQL Basics - JamesDansie/data-structures-and-algorithms GitHub Wiki

SQL Basics

Author: James Dansie

SQL is short for structured query language. It is a language for databases. The underlying data is a 2-D table just like an excel spread sheet. `html

Id Make/Model # Wheels #Doors Type
1 Ford Focus 4 4 Sedan
2 Tesla Roadster 4 2 Sports
3 Kawakasi Ninja 2 0 Motorcycle
4 McLaren Formula 1 4 0 Race
5 Tesla S 4 4 Sedan

Copied from [1] There are a bunch of different ways to access a table. For example if I wanted to select all elements from with no doors, then it would be SQL SELECT * FROM mytable WHERE #Doors = 0. Lets break it down. SELECT * means select all the elemenets, FROM tells use where to look for those elements, and WHERE is the test for what to include. In this case WHERE #Doors = 0 is a test for where the number of doors equals 0.

To add to heroku;

  1. add the heroku addon on the heroku page.
  2. heroku pg:push city_explorer DATABASE_URL --app 2.1 What that does is push local database (city_explorer), to the remote database. It will find the db url because we told it the app name, and the the DATABASE_URL variable will hunt down the remote url.

References [1] - https://sqlbolt.com/lesson/select_queries_review

⚠️ **GitHub.com Fallback** ⚠️