简体   繁体   English

如何匹配数据库中不同表的唯一ID,并根据Java中的唯一ID检索数据?

[英]How to match unique ID from the different table in database and retrieve data according to that unique ID in Java?

Table user in database(postgresql) has unique id for each user, dob, first and last names of the user; 数据库中的表用户 (postgresql)对每个用户,dob,用户的名和姓都有唯一的id; Table points in database has userID and gamePoints columns. 数据库中的表具有userID和gamePoints列。

In java servlet, how do I match and retrieve who exactly that user is with points and output? 在java servlet中,如何使用点和输出匹配和检索该用户的确切位置? Fuzzy Match?? 模糊匹配?

example: 例:

Table user:
userID-name-lastname-dob
1-Edward-Maka-1950
2-Kapu-Aka-1990
3-Park-Lewins-1993

Table points:
userID-gamePoints
1-320
3-3312
2-1001

Isn't this just a matter or writing an appropriate query and parsing the results from the ResultSet in Java? 这不仅仅是一个问题,还是编写一个合适的查询并从Java中的ResultSet中解析结果?

The query should be something like: 查询应该是这样的:

SELECT user.userID, user.name, user.lastname, user.dob, points.gamePoints
FROM user, points
WHERE user.userID = points.userID 
  AND (user.name = ? OR user.lastname = ?)

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

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