I am currently trying to access the primary key by searching for a duplicate field in a database in java using sql statements. My database contains a primary key for the book ids and contains multiple copies of the same book. Those books have the same ISBN but different book ids. Is it possible to extract those unique ids using an SQL select statement? Whenever I run the following select statement, I can only obtain data on one of the copies:
String queryString =
"select bid, title, author, checked from book where isbn = " + ID;
ResultSet resultSet = stmt.executeQuery(queryString);
if (resultSet.next()){
bid = resultSet.getString(1);
title = resultSet.getString(2);
author = resultSet.getString(3);
checked = resultSet.getString(4);
}
resultSet.close();
If I run the same statement in my SQL workbench, all of the data is extracted. How can I extract the unique keys in java?