By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,852 Members | 2,116 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,852 IT Pros & Developers. It's quick & easy.

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

P: 1
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 "CONSECUTIVE" 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
Nov 2 '11 #1
Share this Question
Share on Google+
1 Reply


100+
P: 1,059
The Query should be like this

Expand|Select|Wrap|Line Numbers
  1. SELECT * FROM choosentable where query_result = 0 ORDER BY DATE Limit 0,4
  2.  
Nov 9 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.