mysql - SQL query using MAX and SUBSTRING_INDEX in php -
how execute complex query in drupal
i tried :
$sql = "select max(substring_index(`table_field1`, '/', -1)) mm `tableitems` table_field2=' " .$selvalue."'"; $query = db_query($sql); echo $query;
it returns array echo output.
can please guide me through this. wanted maximum value column in database. , iam getting correct value when tried in mysql directly.
also tried:
$sql = "select max(substring_index(`table_field1`, '/', -1)) mm `tableitems` fieldprefix=' " .$selvalue."'"; $query = db_query($sql); foreach($query $r) echo $r->mm;
but still gives incorrect
you have use below fetch field value in drupal
$sql = "select max(substring_index(`table_field1`, '/', -1)) mm `tableitems` table_field2=' " .$selvalue."'"; $query = db_query($sql)->fetchfield(); print_r($query);
Comments
Post a Comment