Login   Register  
PHP Classes
elePHPant
Icontem

Selecting Conditional Field (Not allowed?)

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Ultimate MySQL  >  All threads  >  Selecting Conditional Field (Not allowed?)  >  (Un) Subscribe thread alerts  
Subject:Selecting Conditional Field (Not allowed?)
Summary:Conditional Field Statement
Messages:1
Author:Damiko Gutom
Date:2013-10-28 04:58:45
 

  1. Selecting Conditional Field (Not allowed?)   Reply   Report abuse  
Picture of Damiko Gutom
Damiko Gutom
2013-10-28 04:58:45
Hi, i'm trying select column with conditional statement, however. it throws an error saying this field is unknown.

$fields = array('id','anime_name','volume',
'(CASE WHEN (DATEDIFF(now(),last_update)) < 2 THEN "new" ELSE NULL END) as update_status');

$sql = MySQL::BuildSQLSelect($table_name,$values,$fields,$sortby,true, $limit);

it gives me We caught the error: Unknown column '(CASE WHEN (DATEDIFF(now(),last_update)) < 2 THEN "new" ELSE NULL END) as update_status' in 'field list' (1509)