CREATE table BooksAuthors (AuthorId INT , BookId INT);
INSERT INTO BooksAuthors VALUES(1,1),(2,2),(3,3),(4,4),(5,5)
SELECT Country FROM Authors
SELECT DISTINCT Country FROM Authors
SELECT * FROM Authors WHERE NAME LIKE "S%"
SELECT COUNT(ID) , Country FROM Authors GROUP by 2
SELECT * FROM Authors order by name
Select all records from the Authors table, and sort the result reversed alphabetically by the column name.
SELECT * FROM Authors order by name DESC
select * from Books WHERE TITLE LIKE "%Great%"
SELECT * FROM Authors WHERE COUNTRY != "USA"
SELECT * FROM Authors WHERE country = "USA" OR country = "India"
SELECT * FROM Authors WHERE Age between 50 and 60
Use the MIN function to select the record with the smallest value of the Age column from the “Authors” table.
SELECT * FROM Authors where age = (select min(age) from Authors)
select ba.authorid , Authors.name , ba.BookId , b.Title from BooksAuthors ba INNER join Books b on ba.BookId = b.Id INNER JOIN Authors on Authors.ID = ba.authorid