Jump to content

mysql - select command


pluginbaby

Recommended Posts

I got a question:

Imagine this table:
id | number
1 | 1
2 | 2
3 | 3
4 | 2
5 | 6

now I make a select in php:

$str = "select id from table X where number=2 limit 1";
$result=mysql_query($str) or die (mysql_error());
$line = mysql_fetch_row ($result);
$id = $line[0];

when I do this, the database selects the first possible id where the number=2.
What I want to do is make the database select a random id where the number=2.
So it would response with id = 2 sometimes, and other times with id = 4

Is this possible?
Link to comment
https://forums.phpfreaks.com/topic/18450-mysql-select-command/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.