2 tables [ scan_dates ] - date - marketUS [ scan_thresholds ] - date - symbol Other fields have been ignored ... The objective would be to create a 2 column return ... column 1 = symbol column 2 = score Query 1 : SELECT date FROM scan_dates WHERE marketUS = 1 ORDER BY dates ASC LIMIT 1,15; Query 2 : i want to query the table scan_thresholds with a date > 15 days ago ( well, with a date which is a result of Query 1 ) ... then for each combination of symbol and date ... compute a score, a score per symbol ... symbol += 2 ^ [row number of the date returned in query 1] ...