Answer the question
In order to leave comments, you need to log in
How to select data from MySql table by minimum date with additional condition?
Help to make a SQL query for a beginner. There is a table accounts consisting of three fields (login, status, date). The status field can have multiple values, such as "active" and "free"
I need to return the string with the smallest date and whose status will be free.
This is how it turns out to select only by the minimum date: Select * from `accounts` where date IN (SELECT MIN(`date`) FROM `accounts`)
This is how I tried to write an additional condition: Select * from `accounts` where date IN (SELECT MIN(`date`) FROM `accounts`) AND `status`= 'free'
I went to learn SQL, I will be very grateful for the help kind people)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question