WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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.