我在使用 MySQL 查询时遇到问题(我是新手,所以放轻松!)。我有一个包含电视节目的网站,并且想根据两个不同的操作(对于自定义时间表)选择两个日期之间播出的剧集(没问题)。基本上,如果用户正在关注(uses_follow_shows)或观看节目(user_watched),我想显示该剧集,所以我想我会有类似下面的内容,但这不起作用。除了我的结果在一侧有一个查询的结果而在另一侧有另一个查询的结果之外,它工作正常。
IE:
name a1 name a
Mistresses (US) 2 Wilfred (US) 2
Mistresses (US) 2 Dexter 2
这是我的查询:
我怎样才能让我所有的名字都在同一列?
SELECT * FROM (
SELECT shows.name, users_follow_shows.user_id a1
FROM show_episode_airdate join
show_episode
on show_episode.episode_id = show_episode_airdate.episode_id join
shows
on shows.imdb_id = show_episode.imdb_id_show join
show_network
on show_network.show_id = shows.id join
network
on show_network.network_id = network.network_id join
users_follow_shows
on shows.id = users_follow_shows.show_id
WHERE show_episode_airdate.airdate BETWEEN '2013-07-20' AND '2013-07-27' and
users_follow_shows.user_id = 2
ORDER by network.network_id ASC) a1
JOIN (
SELECT shows.name, user_watched.user_id a
FROM show_episode_airdate join
show_episode
on show_episode.episode_id = show_episode_airdate.episode_id join
shows
on shows.imdb_id = show_episode.imdb_id_show join
show_network
on show_network.show_id = shows.id join
network
on show_network.network_id = network.network_id join
user_watched
on shows.id = user_watched.show_id
WHERE show_episode_airdate.airdate BETWEEN '2013-07-20' AND '2013-07-27' and
user_watched.user_id = 2
ORDER by network.network_id ASC) a
ON a = a1
任何帮助表示赞赏。谢谢。