我有這個應用程序,java spring boot 和 mysql db。當我嘗試運行以下查詢時,出現此錯誤。 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'email ='[email protected]'' at line 1有誰知道為什么嗎? @Query(value = "SELECT voucher_code FROM voucher INNER JOIN " + "offer ON offer.name = voucher.offer " + " email =:email", nativeQuery = true) List<Voucher> getVouchers(@Param("email") String email);
1 回答

喵喵時光機
TA貢獻1846條經驗 獲得超7個贊
您在兩個條件之間缺少一些東西offer.name = voucher.offer
,email =:email
可能是 a WHERE
,也許是 a AND/OR
。我猜你想要這個:
@Query(value = "SELECT voucher_code FROM voucher INNER JOIN " + "offer ON offer.name = voucher.offer " + "WHERE email =:email", nativeQuery = true) List<Voucher> getVouchers(@Param("email") String email);
添加回答
舉報
0/150
提交
取消