The database is MySQL. The code should look like as below:
public interface UserMapper {
@Select("....")
boolean checkUserExists(@Param("email") String email);
}
Is it possible, and how to write the SELECT SQL? (can Exists be used?)
Yes, you can use EXISTS
@Select("SELECT EXISTS(SELECT 1 FROM my_table WHERE email=#{email})")
boolean checkUserExists(@Param("email") String email);
Note that "SELECT 1" is there for a reason, you don't need to select any actual columns
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With