Hi
I have the following mysql tables:
TRANSACTIONS
customerid int
item varchar
time datetime
What i want to do is select all similar items which have been bought within a time frame of say 2 hours.
the start and end time don't matter, just the difference.
i can do this with a SELECT item, time from transactions order by time;
( call this rs1 and var item1 = rs1.getString("item", var time1 = rs1.getString("time" )
and then iterate over the resulset, but this is expensive.
i.e. SELECT item from transactions where item = item1 and time between time1 and (time1 + 2)
can i do this in a single sql expression?
thanks
I have the following mysql tables:
TRANSACTIONS
customerid int
item varchar
time datetime
What i want to do is select all similar items which have been bought within a time frame of say 2 hours.
the start and end time don't matter, just the difference.
i can do this with a SELECT item, time from transactions order by time;
( call this rs1 and var item1 = rs1.getString("item", var time1 = rs1.getString("time" )
and then iterate over the resulset, but this is expensive.
i.e. SELECT item from transactions where item = item1 and time between time1 and (time1 + 2)
can i do this in a single sql expression?
thanks