In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
How to use Oracle combined with Mybatis to fetch 10 pieces of data from a table? Many novices are not very clear about this. In order to help you solve this problem, the following editor will explain it in detail. People with this need can come and learn. I hope you can gain something.
Original version:
Select top * from student
Of course, we can also write a little more complicated, such as adding some query conditions?
For example, query the information of the first 10 students whose scores are greater than 80.
A version of the where query condition was added:
Select top * from table where score > 80
But! There is no top in oracle! So how to achieve it?
Well, you can use rownum!
Original version in oracle
Select * from student where rownum
< 10 上面这个好像也没有复杂的地方。。但是问题来了,如果我们还希望加上分数大于80呢? 对于我这个oracle初学者来说,真的是费力。在这里就直接贴出来了,希望可以让一些人少费一些力! oracle添加了where查询条件的版本 select * from( select rownum rn,A.* from student where score >80) where rn
< 10 简单分析一下上面的代码。实际上是先通过内嵌的sql语句查询出分数大于80的数据,再选择内嵌sql查询结果中的前10条数据 最后附上mybatis代码? select * from ( select rownum rn, A.* from student A where STATUS = '99' and score ]]># {scores,jdbcType=INTEGER}) where rn # {number,jdbcType=INTEGER}
Both scores and number above are variables
Ps:mybatis takes Oracle sequence and deals with the problem with the same value.
Select 'TRD' | | to_char (sysdate,'yyyymmdd') | | lpad (to_char (SQ_ORD_PURCHASE_ID.nextval), 5,' 0') code from dual
The above mybatis code always gets the value of the same sequence when calling. Query the relevant information and know that it is the cache problem of mybatis:
Add the useCache= "false" flushCache= "false" attribute to:
Select 'TRD' | | to_char (sysdate,'yyyymmdd') | | lpad (to_char (SQ_ORD_PURCHASE_ID.nextval), 5,' 0') is it helpful for you to read the above content after reading it? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.