Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
SQL Basics - RRUG 1/6/2016
Search
kickinbahk
January 06, 2016
Technology
0
140
SQL Basics - RRUG 1/6/2016
Overview of SQL and basic syntax.
kickinbahk
January 06, 2016
Tweet
Share
More Decks by kickinbahk
See All by kickinbahk
OptOutside App
kickinbahk
0
65
Ensuring The Happy Path - Mobile Dev + Test
kickinbahk
0
160
Optionals, Protocols and Extensions - Swift by Example - SoCal Code Camp '16
kickinbahk
0
130
Intro to Elm - RRuG 05/2016
kickinbahk
0
180
WebSockets Intro - Riverside Ruby Group - 03/2016
kickinbahk
0
99
ES2015 and Your Rails App - Riverside Ruby Group
kickinbahk
0
220
Demystifying the Wizardry of Regular Expressions - LV DotNet Meetup - 01/2016
kickinbahk
0
220
Demystifying the Wizardry of Regular Expressions - SoCal Code Camp '15 - LA
kickinbahk
0
250
Becoming a Polyglot Programmer through the Eyes of a Freelance Musician - SoCal Code Camp 15 - LA
kickinbahk
0
160
Other Decks in Technology
See All in Technology
TypeScript 6.0で非推奨化されるオプションたち
uhyo
14
4.9k
リアーキテクティングのその先へ 〜品質と開発生産性の壁を越えるプラットフォーム戦略〜 / architecture-con2025
visional_engineering_and_design
0
6.2k
マルチドライブアーキテクチャ: 複数の駆動力でプロダクトを前進させる
knih
0
9.5k
ある編集者のこれまでとこれから —— 開発者コミュニティと歩んだ四半世紀
inao
5
3.7k
adk-samples に学ぶデータ分析 LLM エージェント開発
na0
3
510
[CV勉強会@関東 ICCV2025] WoTE: End-to-End Driving with Online Trajectory Evaluation via BEV World Model
shinkyoto
0
340
Greenは本当にGreenか? - B/GデプロイとAPI自動テストで安心デプロイ
kaz29
0
130
PostgreSQL で列データ”ファイル”を利用する ~Arrow/Parquet を統合したデータベースの作成~
kaigai
0
160
持続可能なアクセシビリティ開発
azukiazusa1
6
320
SRE視点で振り返るメルカリのアーキテクチャ変遷と普遍的な考え
foostan
2
630
レガシーで硬直したテーブル設計から変更容易で柔軟なテーブル設計にする
red_frasco
4
560
信頼性が求められる業務のAIAgentのアーキテクチャ設計の勘所と課題
miyatakoji
0
120
Featured
See All Featured
GraphQLとの向き合い方2022年版
quramy
49
14k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
2.9k
Building Better People: How to give real-time feedback that sticks.
wjessup
370
20k
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
11
940
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
Reflections from 52 weeks, 52 projects
jeffersonlam
355
21k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
37
2.6k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
1
45
Optimising Largest Contentful Paint
csswizardry
37
3.5k
Rails Girls Zürich Keynote
gr2m
95
14k
The Cult of Friendly URLs
andyhume
79
6.7k
Transcript
SQL BASICS
SQL - Structured Query Language
A Computer Language used for: •Storing, •Manipulating, •Querying
Data stored in relational databases
RELATIONAL DATABASES
A collection of data items organized as a set of
formally-described tables from which data can be accessed or reassembled in many different ways without having to reorganize the database tables.
None
Set of tables with data organized by predefined categories
Each row contains a unique instance of data for the
categories defined by the columns.
None
SQL FLAVORS
•Standard •PostgreSQL •DB2 •MicrosoftSQL •MySQL •Oracle •Informix
SQL is Standardized but different flavors are variations
Compare flavors: http://troels.arvin.dk/db/rdbms/ https://en.wikibooks.org/wiki/SQL_Dialects_Reference
SYNTAX
SELECT
Used to select data from the tables located in a
database.
Two keywords: we need to SELECT information FROM a table.
SELECT "column_name" FROM "table_name"; Syntax:
SELECT Store_Name FROM Store_Information; Syntax:
Store_Name Los Angeles San Diego Los Angeles Boston Result:
Select Multiple Columns
SELECT Store_Name, Sales FROM Store_Information; Syntax:
Store_Name Sales Los Angeles 1500 San Diego 250 Los Angeles
300 Boston 700 Result:
Select All Columns 2 ways…
SELECT Store_Name, Sales, Txn_Date FROM Store_Information; Syntax:
SELECT * FROM Store_Information; Syntax:
Select Distinct
SELECT - all information from a column (or columns) on
a table
This may cause redundancies.
To grab a distinct element, all we need to do
is to add DISTINCT after SELECT
SELECT DISTINCT Store_Name FROM Store_Information; Syntax:
Store_Name Los Angeles San Diego Boston Result:
Where
WHERE - allows filtering the result set based on certain
conditions.
SELECT "column_name" FROM "table_name" WHERE "condition";
SELECT Store_Name FROM Store_Information WHERE Sales > 1000; Syntax:
Store_Name Los Angeles Result:
Where with Or
SELECT * FROM Store_Information WHERE Sales > 1000 OR Txn_Date
= 'Jan-08-1999'; Syntax:
Store_Name Sales Txn_Date Los Angeles 1500 Jan-05-1999 Los Angeles 300
Jan-08-1999 Boston 700 Jan-08-1999 Result:
AND or OR
Allows for compound conditions
SELECT "column_name" FROM "table_name" WHERE "simple condition" [AND|OR] "simple condition";
We can use parenthesis ( ) to indicate the order
of the condition.
SELECT Store_Name FROM Store_Information WHERE Sales > 1000 OR (Sales
< 500 AND Sales > 275); Syntax:
Store_Name Los Angeles Result:
Inner Join
INNER JOIN - returns all rows from multiple tables where
the join condition is met.
SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders INNER JOIN Customers ON
Orders.CustomerID=Customers.CustomerID; Syntax:
Result:
Different Joins INNER JOIN: Returns all rows when there is
at least one match in BOTH tables LEFT JOIN: Return all rows from the left table, and the matched rows from the right table
Different Joins RIGHT JOIN: Return all rows from the right
table, and the matched rows from the left table FULL JOIN: Return all rows when there is a match in ONE of the tables
WHY KNOW SQL IF I KNOW RAILS?
The Rails ORM is an attempt at an abstraction
The SQL queries that the Rails ORM generates for you
may need to be fine-tuned.
Resources Zed Shaw’s Learn SQL the Hard Way: http://sql.learncodethehardway.org/ book/introduction.html
Use the Index Luke: http://use-the-index-luke.com/sql/table- of-contents