1

I have an SQL listing shops, but i would like to random the results on a daily basis.

For example today I list bat 2, 6, 9 etc and tomorrow, 6,1,7,9 etc

Is there a way to implement this?

2
  • Are you trying to select random records or are you trying to randomize the resulting display? Commented May 24, 2010 at 19:23
  • i would like to random the results, but on a dialy basis. Thus if i today i run the query 10 times, the results for today will remain the same order, but if run tomorrow results should change Commented May 24, 2010 at 19:25

2 Answers 2

1

With mysql you can write a query like this

select * from table order by rand(curdate()) limit 3

You can adapt it to other rdbms if you need.

Sign up to request clarification or add additional context in comments.

Comments

0

Is this for a website or...?

You could set up a cron job to run a script on a daily basis and change something to make different shops show up.

For example, you could create a table that contains the ID numbers of shops you want to show, and when your cron job runs it would delete all records from that table and insert new ones, determined randomly or however you want.

1 Comment

yes this is about a website ..... i will think about this, maybe by creating a coloumn with holding a random number that will change daily.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.