Skip to content

Instantly share code, notes, and snippets.

@makeittotop
Created October 10, 2016 06:46
Show Gist options
  • Save makeittotop/88d2f0e53e81551550654a6e8250802b to your computer and use it in GitHub Desktop.
Save makeittotop/88d2f0e53e81551550654a6e8250802b to your computer and use it in GitHub Desktop.
select count(*) from
sakila.actor;
select * from sakila.actor;
select "foo" as "boo";
select actor_id, first_name, last_name
from sakila.actor
where actor_id > 100
order by first_name, last_name;
select * from sakila.country where true;
describe sakila.rental;
select rental_id, inventory_id, return_date from sakila.rental;
select rental_id as rid, inventory_id as iid, return_date as rd from sakila.rental;
describe sakila.film;
select replacement_cost-rental_rate as CostDiff,
film_id as fid, length/60 as TiH from sakila.film;
select * from sakila.actor where first_name='kenneth' and last_name='torn';
select concat(first_name, '-', last_name) as FullName from sakila.actor;
drop database test;
create database test;
use test;
create table employee (ID int primary key not null auto_increment, name nvarchar(50), managerID int);
select * from test.employee ;
insert into test.employee (name, managerID)
select 'abhishek', 3
union all
select 'bryan', 1
union all
select 'james', NULL
union all
select 'foster', 2;
select * from test.employee;
select e1.name from test.employee e1;
select e1.name, e2.name from test.employee e1 cross join test.employee e2;
select e1.name as Employee, ifnull(e2.name, 'Top Motherfucker') as Manager from employee e1 inner join employee e2 on e1.managerID = e2.ID;
select e1.name as Employee, e2.name as Manager from employee e1 left join employee e2 on e1.managerID = e2.ID;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment