数据库选择

时间:2011-10-21 03:41:43

标签: mysql sql

我有3张桌子:

  1. film(film_id,filmname)PK(film_id)
  2. category(category_id,categoryname)PK(category_id)
  3. film_category(包含主键(film_id)和(category_id))
  4. 问题是我要从电影表中选择category_id = 3的所有filmname

    如何做这个mysql select?

2 个答案:

答案 0 :(得分:4)

select
  film.filmname
from
  film
  join film_category
  on film.film_id = film_category.film_id
where
  film_category.category_id = 3

Further info

答案 1 :(得分:0)

SELECT filmname
FROM film NATURAL JOIN film_category
WHERE category_id = 3