getting 4 consective values in a query... this is interesting and hard

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ernestopogi
    New Member
    • Oct 2011
    • 1

    getting 4 consective values in a query... this is interesting and hard

    I have a table
    "search_log "
    that logs all search by client
    here are some of the fields query_date , query_result, query_code

    here is the thing as the owner of the site I want to be able to see a user that searched four times in a row that has no result to be able to save them and stop the from being disappointed

    if a client searches and there is no result it automatically inserts a data like this
    query_date = NOW(),
    query_result = 0,
    query_code = LIKE '%querystring%'


    now i want to be able to find a client that has four "CONSECUTIV E" searches in a row that has four zero "0" query_result


    i am looking for something like this


    query_date = 10/11/2001
    query_result = 0

    query_date = 10/11/2001
    query_result = 0

    query_date = 10/11/2001
    query_result = 0

    query_date = 10/11/2001
    query_result = 0

    they have to be consecutive

    by the way my table is having 3 million records so Can you please advice me a query that can run faster
  • johny10151981
    Top Contributor
    • Jan 2010
    • 1059

    #2
    The Query should be like this

    Code:
    SELECT * FROM choosentable where query_result = 0 ORDER BY DATE Limit 0,4

    Comment

    Working...