i want to add a virtual column to wpdb get_results statement
this is my code and the column gid returns nothing .

$result = $wpdb->get_results ( " SELECT helo AS gid, calendar_id, day FROM table1" ) ;

Please help.

  • What would be in the column? – Jacob Peattie Jan 21 at 6:09
  • @JacobPeattie some user defined text or number – rohithr Jan 21 at 6:13
  • So where's the data coming from? Why would it be a virtual column? Can't you just loop over $result and add the data you want? – Jacob Peattie Jan 21 at 6:22
  • @JacobPeattie in every column gid the data 'helo' should be printed. when i loop $result the column gid is empty, other column have values. – rohithr Jan 21 at 6:43
  • This is really more of an SQL question than WordPress, but have you tried just putting helo in quotes? 'helo' AS gid – Jacob Peattie Jan 21 at 6:45

Your Answer

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

Browse other questions tagged or ask your own question.