Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 663081
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T23:27:01+00:00 2026-05-13T23:27:01+00:00

Does SQLite support seeding the RANDOM() function the same way MySQL does with RAND()

  • 0

Does SQLite support seeding the RANDOM() function the same way MySQL does with RAND()?

$query = "SELECT * FROM table ORDER BY RAND(" . date('Ymd') . ") LIMIT 1;";

From the MySQL Manual about RAND(N):

If a constant integer argument N is
specified, it is used as the seed
value, which produces a repeatable
sequence of column values. In the
following example, note that the
sequences of values produced by
RAND(3) is the same both places where
it occurs.

If not, is there any way to archive the same effect using only one query?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T23:27:01+00:00Added an answer on May 13, 2026 at 11:27 pm

    If you need a pseudo-random order, you can do something like this (PHP):

    $seed = md5(mt_rand());
    $prng = ('0.' . str_replace(['0', 'a', 'b', 'c', 'd', 'e', 'f'], ['7', '3', '1', '5', '9', '8', '4'], $seed )) * 1;
    $query = 'SELECT id, name FROM table ORDER BY (substr(id * ' . $prng . ', length(id) + 2))';
    

    Plus, you can set $seed to the predefined value and always get same results.

    I’ve learned this trick from my colleague http://steamcooker.blogspot.com/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple question: does SQLite support FULL-TEXT searches? If not, is there any way I
From what I Google, sqlite does't support clustered indexes (see Four: Clustered Indexes ),
Does sqlite support the SELECT INTO statement? Actually I am trying to save the
Does the iPhone's SQLite implementation support the full SQLite 3 standard? That is, is
Does anyone know a way to register a persistent UDF in SQLite 3 (using
In the following SQL statement, SQLite sorts correctly but MySQL does not: However, if
Does sqlite support linq-to-SQL?
I need to persist a object. Unfortunately sqlite in android does not support ORM.
Does Sqlite support weak entities or tables that have a composite key where a
I want to update and select one row within one query in SqLite. In

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.