返回“操作数应包含1列”的SQL查询。 [英] SQL query returning "Operand should contain 1 column(s)"

查看:95
本文介绍了返回“操作数应包含1列”的SQL查询。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在处理一个查询,该查询将具有一个表中的所有行,而只有另一个表中的信息有限。

I'm currently working on a query which will have all rows from one table, but only limited information from the other.

我已经尝试使用此表查询:

I've tried working with this query:

SELECT `t`.`uid`, `t`.`cid`, `t`.`id` FROM `tracking` as `t`
JOIN (SELECT DISTINCT(`p`.`id`, `p`.`firstname`, `p`.`lastname`, `p`.`company`) FROM `publishers` as `p`) as `p`
ON `p`.id = `t`.uid

但是,出现主题标题中的错误。

However, I get the error as in the topic heading.

有人在这里看到我在做什么吗?

Can anyone see what I'm doing wrong here?

编辑:

跟踪结构: id int(11)primary ai,cid int(11),uid int(11)。

Structure on tracking: id int(11) primary ai, cid int(11), uid int(11).

发布者的结构:id int(11)primary ai,名字varcher(60),姓氏varchar(60),公司varchar(100) )。

Structure on publishers: id int(11) primary ai, firstname varcher(60), lastname varchar(60), company varchar(100).

示例:
发布者
id 1,名字NIKOLAJ,名字JEPSEN,公司APECHO
id 6,姓ROBERT的姓氏,姓SCOTT的公司FLAPJACK LTD

Sample: publisher id 1, firstname NIKOLAJ, lastname JEPSEN, company APECHO id 6, firstname ROBERT, lastname SCOTT, company FLAPJACK LTD

tracking
id 1,cid 1,uid 1;
id 2,cid 1,uid 6;
id 3,cid 3,uid 1

tracking id 1, cid 1, uid 1; id 2, cid 1, uid 6; id 3, cid 3, uid 1

推荐答案

当然,没有两个发布者可以共享相同的ID,名字,姓氏

Surely no two publishers can share the same id, firstname, lastname, and company!!!

SELECT t.uid
     , t.cid
     , t.id 
  FROM tracking t
  JOIN publishers p
    ON p.id = t.uid;

这篇关于返回“操作数应包含1列”的SQL查询。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆