0

目前,我有这个 SQL 查询来尝试从以下位置获取信息collection_actors

SELECT ca.id_imdb AS IMDb_ID,
       caat.id_collection AS collection_ID,
       ca.data_name AS actors_name

FROM collection_actors AS ca
JOIN collection_actors_assignedto AS caat
ON ca.id_imdb = caat.id_collection
WHERE caat.id_collection = 'tt1104001'

这是两个表的数据库:

collection_actors
    id
    id_user
    id_imdb
    data_name
    date_birth
    date_added
    date_edited
    information_ipaddress


collection_actors_assignedto
    id
    id_user
    id_actor
    id_collection
    date_added
    information_ipaddress

问题是我根本无法从中获取任何信息collection_actors,即使有与 IMDb ID 匹配的数据!我怎样才能让它工作?

4

2 回答 2

0

试试这个:

SELECT ca.id_imdb AS IMDb_ID,
       caat.id_collection AS collection_ID,
       ca.data_name AS actors_name

FROM collection_actors AS ca, collection_actors_assignedto AS caat
WHERE (ca.id_imdb = caat.id_collection) AND (caat.id_collection = 'tt1104001')
于 2013-03-25T14:09:15.403 回答
0

试试这个 sql 片段,这是基于您的代码,但您需要确保 id_collection 中的值与 id_imdb 字段中的数据匹配,否则您将永远不会得到任何结果。

SELECT ca.id_imdb AS IMDb_ID
, caat.id_collection AS collection_ID
, ca.data_name AS actors_name
FROM collection_actors AS ca
INNER JOIN collection_actors_assignedto AS caat ON ca.id_imdb = caat.id_collection
WHERE caat.id_collection = 'tt1104001'
于 2013-03-25T14:13:05.257 回答