1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

  2. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

sql query to get data that have the date column with an value close to user input

Discussão em 'Outras Linguagens' iniciado por Stack, Abril 23, 2021.

  1. Stack

    Stack Membro Participativo

    So i have an table with daily information of different accounts, a user wants to get the data of all accounts based on an date xxxx-xx-xx, but the latest information in some of these accounts are from some days earlier than the date the user want. How can i make an query that gets the information from the date the user want and also info that have the most close date from what he want. I hope i made myself clear, the database is in mysql.

    EDIT:

    bit more of explanation

    SELECT * from `table` where date BETWEEN '2021-01-01' AND userinput


    so the objective is make this query get the latest information, the one closest to the userinput, given the fact that there's multiple rows of the same account but with different dates, the only ones that matters are the ones closer to the date the user has given.

    Continue reading...

Compartilhe esta Página