I am trying to come up with the correct sql for my database query but cannot seem to get it right *INEXPERIENCED* I'm not sure if this should be posted here, as its being done through java and PreparedStatements, or in an sql forum. I shall try here for now if you fine people dont mind.
I have 4 tables all linked appropiately.
CODE
Meet(meetID, meetName)
Event(eventID, meetID, eventName)
Round(roundID, eventID, roundNumber)
Competitor(CompetitorID, roundID, name, timeSet)
You can see in my Competitor table i have a field Time_Set. I need to return the 3 fastest times, in round 1, for the event 100M Run. My whole database is saved under the name Register, although i dont know if its need for this. I have attempted somthing along the lines of:
CODE
PreparedStatement ps = null;
ResultSet rs = null;
try {
con = DatabaseUtils.connect(DRIVER, URL);
ps = con.prepareStatement("SELECT Time_Set FROM Competitor WHERE Round.Round_Number = VALUES (?) AND Event.Event_Name = VALUES (?) ORDER BY Time_Set ASC");
ps.setString(1, "Round_1");
ps.setString(2, "100M Run");
rs = ps.executeQuery();
while (rs.next()) {
String s = rs.getString("Time_Set");
System.out.println(s);
}
}
I am being returned some lovely undefined function errors as my sql is problably embarresingly pathetic. Any help would be great.
cheers