我写了这个并得到了错误,只是启动了sql,所以我不知道是什么问题。 数据库是sakila-https://dev.mysql.com/doc/sakila/en/sakila-structure.html,查询是要找到在电影“ AFRICAN EGG”中扮演的演员的名字
-(void)viewDidAppear:(BOOL)animated
{
if(!self.loadingPropeller.hidden){
[self.loadingPropeller startPropeller];
}
}
答案 0 :(得分:1)
您需要在where语句中包含一个比较
SELECT a.first_name, a.last_name
FROM actor a
WHERE a.actor_id in -- probably actor id
(SELECT actor_id
FROM film_actor
WHERE film_id in -- probably film id
(SELECT film_id
FROM film
WHERE title = "AFRICAN EGG"))
您也可以通过联接来实现
SELECT a.first_name, a.last_name
FROM actor a join film_actor fa on
a.actor_id = fa.actor_id
JOIN film f ON
fa.film_id = f.film_id
WHERE f.title = "AFRICAN EGG";
答案 1 :(得分:0)
根据您的要求使用以下查询。
SELECT a.first_name, a.last_name
FROM actor a
WHERE a.id IN
(SELECT fa.actor_id
FROM film_actor fa
WHERE fa.film_id IN
(SELECT film_id
FROM film
WHERE title = "AFRICAN EGG"))
SELECT
a.first_name,
a.last_name
FROM actor a
JOIN film_actor fa ON fa.film_actor = a.id
JOIN film f ON f.id = fa.film_id
WHERE f.title = "AFRICAN EGG";