• Resolved wombelt

    (@wombelt)


    hello,

    Im trying to get Random Entries from my Table.

    I dont understand why this does not work:

    $rand_wpkeys = $wpdb->get_results( “SELECT * FROM $table_name WHERE thekeywords LIKE ‘mykeyword’ ORDER BY RAND() LIMIT $numposts” );

    without “ORDER BY RAND() LIMIT $numposts” it works.
    Any Ideas?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hmm. I was not able to replicate. I was able to run:

    SELECT * FROM $wpdb->posts WHERE post_name LIKE '%chicken%' ORDER BY RAND() LIMIT 100

    And I got some random results

    Maybe give us some more context, such as PHP/MySQL versions, and perhaps maybe a larger code snippet. Consider posting in the Advanced Forum.

    Thread Starter wombelt

    (@wombelt)

    Well, thanks Rocco.

    I have forgotten to use the “%” for my keyword: %’mykeyword%’

    Now its work –

    thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wpdp rand’ is closed to new replies.