我似乎无法让这个简单的查询工作:
SELECT *
FROM agendas2,
(SELECT COUNT(*) AS unique_clip_views
FROM
(SELECT *
FROM uniquevideoviews, agendas2
WHERE uniquevideoviews.clip_id = agendas2.clip_id
) AS uc
) as agendas
它返回:
错误#1060 - 重复列名称' clip_id'
当我硬编码where子句值时,它可以正常工作:
SELECT *
FROM agendas2,
(SELECT COUNT(*) AS unique_clip_views
FROM
(SELECT *
FROM uniquevideoviews, agendas2
WHERE uniquevideoviews.clip_id = '0123456789'
) AS uc
) as agendas
我知道这必须是简单的事情,我已经花了大约四个小时进入圈内。
答案 0 :(得分:-1)
两个表都有/// reference
列,因此Id
代替select *
。
答案 1 :(得分:-1)
Clip_id在两个表议程和uniquevideovies中。 您应该使用tables \子查询别名和字段名称。或者像这样更改内部查询
SELECT *
FROM agendas2,
(SELECT COUNT(*) AS unique_clip_views
FROM
(SELECT 1
FROM uniquevideoviews, agendas2
WHERE uniquevideoviews.clip_id = agendas2.clip_id
) AS uc
) as agendas
这样就可以避免使用同名字段的双重列表。
Owever,我相信你的查询有一些麻烦。为什么你从agendas2中选择两次?在主要关系中,您不要将agendas2与uniquevideo视图联系起来。