owner Posted September 28, 2009 Report Share Posted September 28, 2009 Could someone help me convert this over to the IP.Board style SELECT * FROM `test` WHERE id >= (SELECT FLOOR( MAX(id) * RAND()) FROM `test` ) ORDER BY id LIMIT 1 to $this->DB->build( array( 'select' => '*', 'from' => 'test', 'where' => 'id >= (SELECT FLOOR( MAX(id) * RAND()) FROM `test` )', 'limit' => array( 0, 5 ) ) ); The bottom code doesn't work, but I need to convert the query above to work with the bottom one. Thanks in advance! -owner Quote Link to comment Share on other sites More sharing options...
Management Michael Posted September 28, 2009 Management Report Share Posted September 28, 2009 Don't think it's possible to have a select query inside where. What about this instead? $this->DB->query("SELECT * FROM `test` WHERE id >= (SELECT FLOOR( MAX(id) * RAND()) FROM `test` ) ORDER BY id LIMIT 1"); Quote Link to comment 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.