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 7035115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:15:59+00:00 2026-05-28T01:15:59+00:00

Let us say I have a table called animals that looks like this: 1

  • 0

Let us say I have a table called animals that looks like this:

1 red     fox
2 blue    elephant
3 red     dog
4 yellow  cat
5 green   mouse
6 blue    rat

In effect what I would like to do is make a temporary table (a virtual table) that only contains rows of the value I specify. For example red:

1 red     fox
3 red     dog

and then grab a random row from this virtual table.

What I don’t want to do is to permanently create these tables and have to constantly update them grabbing information from the main animals table. I would like to do this on the fly and quickly using some sort of subquery, view, temporary table or whatever you would like to call it.

Please keep in mind that I am a complete php noob and could use as much clarification as possible involving syntax.

  • 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-28T01:15:59+00:00Added an answer on May 28, 2026 at 1:15 am

    You can use a sql query like following

    SELECT * FROM table
    where color = 'red'
    ORDER BY RAND()
    LIMIT 1 
    

    You can change limit to any number of rows that you want to fetch

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

Sidebar

Related Questions

Let's say I have a table called my_table that looks like this: id |
Let's just say I have a table called TABLE_NAME that looks like this: id
Let's say I have a simple stored procedure that looks like this (note: this
Let's say I have a table called Customer, defined like this: Id Name DepartmentId
let's say that I have a table called Items (ID int, Done int, Total
Let's say I have a table like this a | b | c |
Let's say I have an edit view that is strongly-typed to a table called
Let's say that hypothetically I have a table called Products with a primary key
Let's say that I have a class/table called Images that, as it stands right
Let's say I have a table in my database called Orders that has the

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.