mysql - Select more columns with GROUP_CONCAT( ) according to lowest date -


i have 1 table accounts. have written following query

chk_account= mysql_query("select group_concat( distinct user_id ) userlist                                  `accounts`                                  "); 

from users id only. query want fetch data price , date column name price , created need select lowest date

i have table structure this:

id      user_id         price       created 1       31              10          2013-04-09 17:30:15 2       32              20          2013-04-10 20:24:40 3       31              30          2013-04-11 04:44:25 4       33              40          2013-04-12 05:47:18 5       34              50          2013-04-13 19:54:15 6       34              50          2013-04-14 14:27:15 7       35              10          2013-04-15 13:54:45 8       35              60          2013-04-16 12:24:35 9       35              10          2013-04-17 20:34:10 

i suspect want earliest date , price each user. can using group_concat(), using query such as:

select user_id,        substring_index(group_concat(price order created), ',', 1) price,        min(created) accounts group user_id 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -