current position:Home>SQL statement fuzzy query and time interval filtering

SQL statement fuzzy query and time interval filtering

2022-01-27 04:35:34 Rolling mill

Recently, I made an interface parameter, which is the project of querying the database , Make up for it sql sentence

Fuzzy query ( The simplest way to write % arbitrarily %)

select * from log where seatname like'%192.168.15.121%'

One requirement is to query all the data in the database start time field in the time interval selected by the two time selectors and flashback the query according to the creation time of each data , Then consider performance ( Too much database data ) I also made paging query function , therefore sql The sentences are longer

 sql=`SELECT * FROM log  where username like '%${prams}%' and start_time >= '${setTime}' AND start_time <= '${endTime}' ORDER BY CreatedTime DESC LIMIT ${(page-1)*20},20`;

copyright notice
author[Rolling mill],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/01/202201270435325031.html