ts2000abc Posted February 19, 2007 Share Posted February 19, 2007 hi, If i make mysql query using RAND(), can i give value or some other syntax to rand() so it wouldn't return 0/null results? now my query ends like ... "ORDER BY RAND() LIMIT 3" and this sometimes gives 0 answers. [T:S] Quote Link to comment https://forums.phpfreaks.com/topic/39143-mysql-rand-no-0null-results-how/ Share on other sites More sharing options...
fenway Posted February 19, 2007 Share Posted February 19, 2007 That has nothing to do with RAND().... Quote Link to comment https://forums.phpfreaks.com/topic/39143-mysql-rand-no-0null-results-how/#findComment-188521 Share on other sites More sharing options...
ts2000abc Posted February 19, 2007 Author Share Posted February 19, 2007 ??? what is it then? mysql congif?? Quote Link to comment https://forums.phpfreaks.com/topic/39143-mysql-rand-no-0null-results-how/#findComment-188523 Share on other sites More sharing options...
fenway Posted February 19, 2007 Share Posted February 19, 2007 Impossible... you're telling me that if you drop the ORDER BY clause, but leave the limit 3, you get results? Quote Link to comment https://forums.phpfreaks.com/topic/39143-mysql-rand-no-0null-results-how/#findComment-188553 Share on other sites More sharing options...
ts2000abc Posted February 19, 2007 Author Share Posted February 19, 2007 most of the times that i run this query i get the results OK, sometimes (as it is random query) i just get 0 as a result. i was just thinking is there a way to set value for minimum output (as the LIMIT 3 sets the max)... Quote Link to comment https://forums.phpfreaks.com/topic/39143-mysql-rand-no-0null-results-how/#findComment-188598 Share on other sites More sharing options...
fenway Posted February 19, 2007 Share Posted February 19, 2007 There is no concept of "minimum" -- you get as many rows as match your query, and you can limit how many you get back. Ordering by anything, including RAND(), has no way of "changing" the number of rows that match! Quote Link to comment https://forums.phpfreaks.com/topic/39143-mysql-rand-no-0null-results-how/#findComment-188621 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.