为什么我在eclipse中运行此查询时遇到错误?
java.sql.SQLException: ORA-00933: SQL command not properly ended
代码:
String policy = "select p.policy_id,i.insurance_type,c.reason,i.insured_amount,i.max_claim_amount,c.claim_status from claim as c join policy as p on c.policy_id=p.policy_id join insurance as i on p.insurance_id=i.insurance_id where c.user_id=?";
PreparedStatement policyst = con.prepareStatement(policy);
policyst.setString(1, userId);
ResultSet policyrs = policyst.executeQuery();
答案 0 :(得分:3)
Oracle不支持as
表别名;你应该删除它们:
SELECT p.policy_id,
i.insurance_type,
c.reason,
i.insured_amount,
i.max_claim_amount,
c.claim_status
FROM claim c
JOIN policy p ON c.policy_id = p.policy_id
JOIN insurance i ON p.insurance_id = i.insurance_id
WHERE c.user_id = ?
答案 1 :(得分:2)
从您的陈述中删除“AS”字样