我是Ibatis
的新手并且还在学习它。我遇到了这个需要转换为Ibatis
查询的SQL查询。
我尝试使用CDATA
标记并尝试了一些迭代器标记,但它并没有为我解决问题。这是我的疑问:
SELECT comp_small_name
FROM table_company
WHERE companyid IN (
SELECT agentid
FROM (
SELECT *
FROM table_comp_price
WHERE companyid = #compid#
ORDER BY companyid DESC
WHERE ROWNUM <= 2
)
)
这适用于Oracle
数据库。
答案 0 :(得分:1)
Method 1
SELECT comp_small_name
FROM table_company
WHERE companyid IN (
SELECT agentid
FROM (
SELECT *
FROM table_comp_price
WHERE companyid = #compid
ORDER BY companyid DESC
WHERE <![CDATA[ ROWNUM <= 2 ]]>
)
)
或者您也可以使用以下Method 2
:
SELECT comp_small_name
FROM table_company
WHERE companyid IN (
SELECT agentid
FROM (
SELECT *
FROM table_comp_price
WHERE companyid = #compid
ORDER BY companyid DESC
WHERE ROWNUM <= 2
)
)