MySQL Rank & $wpdb

I need a rank column in my MySQL statement, for example:

SET @rank=0;
SELECT @rank:=@rank +1 as rank, player, points 
FROM my_table

Is there a way to use the above with $wpdb? WordPress doesn’t like having 2 lines, the ‘;’ causes it to blow up.

Read More
$mydata = $wpdb->get_results($wpdb->prepare(" --MySQL SELECT Statement-- "));

Thank you.

Related posts

Leave a Reply

1 comment

  1. You might try: SELECT NULL AS rank, player, points FROM my_table
    Then write a tiny loop to fill in the value for rank in each returned record?!?!?

    It’s a workaround rather than a solution but in the end, you’ll have what you need.