Hey there,
I am building a small database app where I allow users to input and retrieve information in and out of database.
As part of my application I have this table courses and a java file Course.java that models a Course object. My Course objects have field variables courseID, courseName and so on.
As part of my app, I have to retrieve all rows from my course table and I put courseName of every object built out of the rows in a ComboBox.
After this, I have to write to another table and put courseID in there, but ComboBox's selected item is a courseName, not a courseID. Now, I know I can do a "SELECT courseID FROM courses WHERE coursName = " + ComboBox.getSelectedItem(), but that seems messy since two courseIDs may be returned by that SELECT statement.
Would anyone tell me please how to do this?
thank you in advance.