Welcome Guest, Not a member yet? Register   Sign In
database error when using DISTINCT and ORDER BY
#5

(This post was last modified: 05-05-2017, 10:32 PM by corey.)

my problem solved by using

Code:
SELECT ANY_VALUE(message_user_name), ANY_VALUE(message_user_id) FROM cms_inbox GROUP BY message_user_id ORDER BY ANY_VALUE(message_time)

adding ANY_VALUE()  to SELECT and ORDER BY solved my problem but causing problem in view file 

this is showing when print_r uses 

Code:
[color=#333333][size=medium][font=Ubuntu, sans-serif]Array ( [0] => Array ( [ANY_VALUE(message_user_name)] => user_1 [ANY_VALUE(message_user_id)] => 2 ) [1] => Array ( [ANY_VALUE(message_user_name)] => user_2 [ANY_VALUE(message_user_id)] => ) )

and when i use foreach is view file 

Code:
foreach ( $inbox as $var) { echo $var->message_user_name; }


it shows error 

Code:
[color=#333333][size=medium][font=Ubuntu, sans-serif]Message: Trying to get property of non-object[/font][/size][/color]
Reply


Messages In This Thread
RE: database error when using DISTINCT and ORDER BY - by corey - 05-05-2017, 10:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB