SELECT ch.* FROM (SELECT * FROM Chat ORDER BY chDateTime DESC LIMIT 50000) Chat ch WHERE (chMessage LIKE '%{StockHunk}%' or chUserName='StockHunk') AND 1=1 ORDER BY chDateTime DESC, chRecordID DESC LIMIT 40