Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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