我有一个哈希表:
table: hash
hash_id hash
'1', 'xKsKoM'
'2', 'taahmD'
'3', '23PNiJa'
运行查询时:
select *
from
where hash in ('taahmD', 'taahmD')
结果(一行):
1. taahmD
但我需要回归(两行,......行):
taahmD
2. taahmD
它只返回一行 - 需要返回两个(重复)。
解决方案是什么?
答案 0 :(得分:0)
例如,您可以使用两个值连接某个表。 (已编辑添加单词INNER)
select t.*
from <your table> t
INNER JOIN (select 1 as a from dual
union all
select 2 as a from dual) d on 1=1
where hash in ('taahmD')
或请求表两次
select t.*
from <your table> t
where hash in ('taahmD')
union all
select t.*
from <your table> t
where hash in ('taahmD')
答案 1 :(得分:0)
但我需要返回(两行,...... nlines)
您可以使用union,但对于n
行,它会很麻烦,另一种方法是加入生成n
行的简单分层查询。以下是5行(Oracle版本)的示例:
select hash
from hash cross join (select null from dual connect by level <= 5)
where hash = 'taahmD'