V
V
Voldemar212021-12-15 00:24:37
Python
Voldemar21, 2021-12-15 00:24:37

How to correctly select data on a specific date in sqlite?

The essence of the question is that there is a database table of this form "id with autoincrement, user_id, data, task" in the first column, simple numbering, in the second column there is a binding to the user id, in the data column the date specified by the user is written, in the task column the task specified by the user is written or a list of cases for a specific date that he specified.
Tell me how I can implement such a query in the database: So that when the user enters a date, he gets a list of tasks for that date. That is, the user filled a bunch of dates with tasks and wanted to see the tasks for the desired date, and he was shown exactly those tasks, and not all at once or nothing.

"SELECT * FROM `task_list` WHERE `user_id` = ? AND `data` BETWEEN '12.12.2021' AND '13.12.2021' ORDER BY `data`"

With such a request, it displays all the tasks that fall into the range, but I don’t need it.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan, 2021-12-15
@FCKJesus

SELECT task FROM task_list WHERE user_id = ? AND data = ? ORDER BY data DESC;

This query will display tasks for the date you need, sorted by date

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question