0

I have this application, java spring boot and mysql db. When i try to run the following query, i get this error. 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

Does anyone know know why?

    @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
  • Shouldn't there be an "AND" before email =? Commented Oct 11, 2019 at 4:23

1 Answer 1

3

You are missing something between the two conditions offer.name = voucher.offer and email =:email, probably a WHERE, perhaps an AND/OR. I guess you wanted this:

@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);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.