简体   繁体   English

德比数据库搜索

[英]Derby Database-Search

I have linked my database to my project, have called the entity classes from the db and bound the db to a jtable. 我已将数据库链接到我的项目,已从db调用实体类并将db绑定到jtable。 That's all well and good. 这一切都很好。 But now I need to manipulate the database. 但现在我需要操纵数据库。

(I cannot submit any code for overview, as I do not know where to start) (我无法提交任何代码以供概述,因为我不知道从哪里开始)

What I have done so far 到目前为止我做了什么

  1. Insertion of a Item 插入项目
  2. Deleting of a Item 删除项目
  3. Updating of a Item 更新项目

I now need to extract the first, second and last record of the database. 我现在需要提取数据库的第一个,第二个和最后一个记录。 I am using the .obj file to manipulate the Derby DB. 我正在使用.obj文件来操作Derby DB。

you can have one query to perform selection of record 1,2 and last together doing so. 您可以有一个查询来执行记录1,2的选择,并最后一起执行此操作。 I have supposed you have a date field to know the order of the records first/last records. 我假设你有一个日期字段来知道记录的第一个/最后一个记录的顺序。 :D :d

SELECT *
FROM mytable
WHERE <conditions>
ORDER BY date DESC
LIMIT 2

UNION ALL

SELECT *
FROM mytable
WHERE <conditions>
ORDER BY date ASC    
LIMIT 1

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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