Skip to content

Instantly share code, notes, and snippets.

@Shiti
Created October 4, 2013 09:50
Show Gist options
  • Save Shiti/6823577 to your computer and use it in GitHub Desktop.
Save Shiti/6823577 to your computer and use it in GitHub Desktop.
1.EXPLAIN SELECT
f.title, a.first_name,a.last_name
FROM
film f
JOIN
film_actor fa USING (film_id)
JOIN
actor a USING (actor_id);
2.EXPLAIN SELECT
CONCAT(c.first_name, c.last_name) AS name, addr.address
FROM
customer c,
(SELECT
a.address, a.address_id
FROM
address a
WHERE
a.city_id IN (SELECT
c.city_id
FROM
city c, country cc
WHERE
c.country_id = cc.country_id
AND cc.country = 'Cameroon')) addr
WHERE
c.address_id = addr.address_id;
4.EXPLAIN SELECT
film_id, actor_id
FROM
sakila.film_actor
WHERE
actor_id = 1
UNION ALL SELECT
film_id, actor_id
FROM
sakila.film_actor
WHERE
film_id = 1 AND actor_id <> 1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment