i have table with filmname and actors column in sql server 2005
i want the sql query to get all the actors of the film starred by both "bradpitt" and "rusellcrowe"
the table design is as follows
CREATE TABLE [dbo].[mytable](
[actors ] [nchar](10) NULL,
[filmname] [nchar](10) NULL,
) ON [PRIMARY]
get the film where both bradpitt and rusellcrowe (russellcrowe?) exist for that film... which then gives you the actors
SELECT
actors
FROM
dbo.MyTable M1
WHERE
EXISTS (SELECT * FROM
dbo.MyTable M2
WHERE
M2.actors = 'bradpitt' AND M1.filmname. = M2.filmname)
AND
EXISTS (SELECT * FROM
dbo.MyTable M3
WHERE
M3.actors = 'rusellcrowe' AND M1.filmname. = M3.filmname)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.