Reputation: 4249
I am currently experimenting with using nested select statements but my subqueries are generating NULL
values. What am I doing wrong?
SELECT filmid,datetime,title,description,
(
SELECT name
FROM fec_client
WHERE filmid = 'fec_film.filmid'
),
(
SELECT rating_motivation
FROM fec_rating_report
WHERE filmid = 'fec_film.filmid'
)
FROM fec_film
ORDER BY datetime DESC
Upvotes: 0
Views: 57
Reputation: 13755
remove the quotes, otherwise you are not comparing to the values in the SQL but to strings
SELECT filmid, datetime, title, description,
( SELECT name FROM fec_client WHERE filmid = fec_film.filmid ) AS name,
( SELECT rating_motivation FROM fec_rating_report WHERE filmid = fec_film.filmid ) AS rating
FROM fec_film ORDER BY datetime DESC
p.s. you can also name those columns using the 'AS' keyword
Upvotes: 4