Page 67 - SQL
P. 67
Examples
View all authors (view live example):
SELECT * FROM Authors;
View all book titles (view live example):
SELECT * FROM Books;
View all books and their authors (view live example):
SELECT
ba.AuthorId,
a.Name AuthorName,
ba.BookId,
b.Title BookTitle
FROM BooksAuthors ba
INNER JOIN Authors a ON a.id = ba.authorid
INNER JOIN Books b ON b.id = ba.bookid
;
Countries Table
In this example, we have a Countries table. A table for countries has many uses, especially in
Financial applications involving currencies and exchange rates.
Live example: SQL fiddle
Some Market data software applications like Bloomberg and Reuters require you to give their API
either a 2 or 3 character country code along with the currency code. Hence this example table has
both the 2-character ISO code column and the 3 character ISO3 code columns.
Countries
(view table)
Id ISO ISO3 ISONumeric CountryName Capital ContinentCode CurrencyCode
1 AU AUS 36 Australia Canberra OC AUD
2 DE DEU 276 Germany Berlin EU EUR
2 IN IND 356 India New Delhi AS INR
3 LA LAO 418 Laos Vientiane AS LAK
4 US USA 840 United States Washington NA USD
https://riptutorial.com/ 49

