0

現在、ネストされた select ステートメントを使用して実験していますが、サブクエリがNULL値を生成しています。私は何を間違っていますか?

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
4

1 に答える 1

4

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

于 2012-04-16T11:58:40.547 に答える