php - Distinct Values from MySQLi Query -


i trying show unique userids (userids (0,1,2,3,4,5,6,7,8,9 etc...) query running. tried using distinct in query, shows me unique values of rows have 2 or more of same userid.

is there way can use php show unique values. weak points arrays , makes more complicated because using data mysqli query.

example right have query (lets group rentpaid desc , rent total 800.00 users):

  userid  rentpaid  rentmonth   2--------800.00------april     1--------500.00------april     3--------400.00------april     3--------400.00------april     1--------200.00------april     1--------100.00------april   

example desired output:

  userid  rentpaid  rentmonth    2--------800.00------april     1--------500.00------april     3--------400.00------april   

can mysql because tried distinct , wouldn't work, how php?

query:

        select                   properties.*,             leases.*,             users.userid, users.primaryphone,             concat(users.userfirstname,' ',users.userlastname) user,             admins.adminname, payments.*                     properties             left join leases on properties.propertyid = leases.propertyid             left join assigned on properties.propertyid = assigned.propertyid             left join admins on assigned.adminid = admins.adminid             left join users on properties.propertyid = users.propertyid             left join payments on properties.propertyid = payments.propertyid                     payments.rentmonth = '$currentmonth' ,             payments.rentyear = '$currentyear' 

edit: please excuse formatting, first post.

edit: added query....its long, works lol. want unique userids (no double or triple userids etc...)

i suspect want:

select userid, max(rentpaid) maxrentpaid, rentmonth yourtable rentmonth = "april" group userid order maxrentpaid 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -