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
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
kickinbahk
January 06, 2016
Technology
0
150
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
74
Ensuring The Happy Path - Mobile Dev + Test
kickinbahk
0
170
Optionals, Protocols and Extensions - Swift by Example - SoCal Code Camp '16
kickinbahk
0
140
Intro to Elm - RRuG 05/2016
kickinbahk
0
190
WebSockets Intro - Riverside Ruby Group - 03/2016
kickinbahk
0
110
ES2015 and Your Rails App - Riverside Ruby Group
kickinbahk
0
240
Demystifying the Wizardry of Regular Expressions - LV DotNet Meetup - 01/2016
kickinbahk
0
230
Demystifying the Wizardry of Regular Expressions - SoCal Code Camp '15 - LA
kickinbahk
0
260
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
us-east-1 に障害が起きた時に、 ap-northeast-1 にどんな影響があるか 説明できるようになろう!
miu_crescent
PRO
13
4.1k
開発組織の課題解決を加速するための権限委譲 -する側、される側としての向き合い方-
daitasu
5
340
JAWS DAYS 2026 ExaWizards_20260307
exawizards
0
380
クラウド時代における一時権限取得
krrrr38
1
180
LINE Messengerの次世代ストレージ選定
lycorptech_jp
PRO
19
7.7k
OCI Security サービス 概要
oracle4engineer
PRO
2
13k
Databricksアシスタントが自分で考えて動く時代に! エージェントモード体験もくもく会
taka_aki
0
370
Kaggleの経験が実務にどう活きているか / kaggle_findy
sansan_randd
7
1.3k
オレ達はAWS管理をやりたいんじゃない!開発の生産性を爆アゲしたいんだ!!
wkm2
4
460
タスク管理も1on1も、もう「管理」じゃない ― KiroとBedrock AgentCoreで変わった"判断の仕事"
yusukeshimizu
5
2.3k
20260305_【白金鉱業】分析者が地理情報を武器にするための軽量なアドホック分析環境
yucho147
2
210
新職業『オーケストレーター』誕生 — エージェント10体を同時に回すAgentOps
gunta
4
1.7k
Featured
See All Featured
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.7k
Max Prin - Stacking Signals: How International SEO Comes Together (And Falls Apart)
techseoconnect
PRO
0
110
How to make the Groovebox
asonas
2
2k
Side Projects
sachag
455
43k
What Being in a Rock Band Can Teach Us About Real World SEO
427marketing
0
190
Are puppies a ranking factor?
jonoalderson
1
3.1k
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
84
sira's awesome portfolio website redesign presentation
elsirapls
0
190
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2.4k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
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