1

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.

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

Thank you.

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.