W
W
Web__Nikita032020-04-21 14:17:55
MySQL
Web__Nikita03, 2020-04-21 14:17:55

How to find row in database by column value?

I am writing a small rest service using Spring Boot. I have an entity and an interface that inherits from CrudRepository. I need to get my entity with the necessary data, which must be found by the value of the column. I have only seen repository.findById(). Question: is it possible to find a line in the database by value, not by Id. I am using MySQL. In theory, you can write a sql query, so there must be such a function. So right?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2020-04-21
@Web__Nikita03

Of course you can. Do you read the documentation?

S
Stalker_RED, 2020-04-21
@Stalker_RED

select user_id, username, email
  from my_table
  where email='[email protected]'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question