简体   繁体   中英

join another table without a join for limit at one

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

return me an error :

1241 - Operand should contain 1 column(s)

i need o select an other table without join

Thank you

Your subquery can return only one column and one row (ie one value) when used as a column expression. If you need more than one column from the table in the subquery, you will need more than one subquery. Eg:

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

Here is some good reading on subqueries: Subquery Fundamentals

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM