lundi 23 mars 2015

sql syntax error when using update select and inner join

Hi i am trying to update a column in my database, if warranty is equal to yes i want total to be equal to zero but i keep getting an sql syntax error would be grateful if anyone could help me!!



public void settled()

{

try {
Class.forName("org.sqlite.JDBC");

Connection conn = DriverManager.getConnection("jdbc:sqlite:xxxxxxx");
System.out.println("Opened database successfully");
Statement statement = conn.createStatement();

String sql=("UPDATE Bookings set total= '0' SELECT Bookings.BookingID,Bookings.BookingDate,Bookings.settled,Vehicles.hasWarranty FROM Bookings JOIN Vehicles ON Bookings.CustomerID=Vehicles.CustomerID WHERE hasWarranty='yes'");
ResultSet rs=statement.executeQuery(sql);




jTable1.setModel(DbUtils.resultSetToTableModel(rs));
statement.close();
conn.close();

}
catch ( Exception e ) {

System.err.println( e.getClass().getName() + ": " + e.getMessage() );
}
}

Aucun commentaire:

Enregistrer un commentaire