select random query in mysql using asp
Posted on 2006-11-20
I want to select random records from mysql database returning a set amount of results, I have got it working but it also generates no fixed amount of records returned. Can anyone suggest what I have done wrong.
Here is my code
start_marker = rnd() * 1000000
strSQL = "select offers.id, manufacturers.manufacturers, models.model, contract_name, "
strSQL = strSQL & "offer_ppm as price "
strSQL = strSQL & "from offers "
strSQL = strSQL & "join manufacturers on offers.offer_manufacturer = manufacturers.id "
strSQL = strSQL & "join models on offers.offers_model = models.id "
strSQL = strSQL & "join finance_type on offers.offer_finance = finance_type.id "
strSQL = strSQL & "where random_number > '" & start_marker & "' and offer_finance <> '1' "
strSQL = strSQL & "order by random_number"
RecordSet.open strSQL, dbConn
if not(RecordSet.EOF and RecordSet.EOF) then