简体   繁体   中英

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; Table points in database has userID and gamePoints columns.

In java servlet, how do I match and retrieve who exactly that user is with points and output? 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?

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 = ?)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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