我想从涉及许多表的查询中检索数据。我有一个查询如下
String sql = "SELECT "
+ "s.Food_ID AS 'Sales_FoodID', "
+ "f.Food_Name AS 'foodName' "
+ "FROM Ordering o, Sales s, Food f"
+ " WHERE o.Table_No = " + tableNo + ""
+ " AND o.Paid = '" + NOT_PAID + "'"
+ " AND s.Order_ID = o.Order_ID"
+ " AND f.Food_ID = s.Food_ID;";
resultSet = statement.executeQuery(sql);
运行程序时没有发现错误,但是在我添加此行以获取表的列数据后:
String orderID = resultSet.getString("foodName");
我收到了这个错误:
java.sql.SQLException: Column not found
有谁知道为什么?