【问题标题】:join another table without a join for limit at one加入另一个表而没有加入限制在一个
【发布时间】:2014-05-27 16:37:22
【问题描述】:
SELECT op.id,op.nome,op.cognome,op.ore_giornaliere,
(select tp.* from turni_preconf as tp where tp.tot_ore =  op.ore_giornaliere limit 5,1)             
FROM operatori as op

给我一​​个错误:

1241 - 操作数应包含 1 列

我需要选择另一个没有加入的表

谢谢

【问题讨论】:

  • 您想要的结果是什么?为什么不能使用JOIN

标签: mysql sql phpmyadmin


【解决方案1】:

当用作列表达式时,您的子查询只能返回一列和一行(即一个值)。如果您在子查询中需要来自表的多个列,则您将需要多个子查询。例如:

SELECT t1.a, t1.b
(SELECT TOP 1 t2.a FROM t2 WHERE something = true) as c,
(SELECT TOP 1 t2.b FROM t2 WHERE something = true) as d
FROM t1

这里有一些关于子查询的好读物:Subquery Fundamentals

【讨论】:

  • 好的,谢谢,但是如果你展示一个带有我的参数的实际例子,对我来说更好......
猜你喜欢
  • 2021-04-23
  • 2014-03-12
  • 1970-01-01
  • 1970-01-01
  • 2018-12-23
  • 1970-01-01
  • 1970-01-01
  • 2020-04-15
  • 2011-07-17
相关资源
最近更新 更多