mysql - How to group field data? -
i have sql query show data
"select `artikel`.`foto_naam`, `fotografer`.`id`, `fotografer`.`name_fotografer`, `customer`.`first_name`, `customer`.`last_name`, `fotografer`.`domain_name`, `fotografer`.`email`, `order`.`invoice_no`, `order`.`order_cost`, `order`.`total_cost`, `order`.`invoice_date`, `order`.`payment`, `order`.`status` `artikel_group` inner join `artikel` on `artikel`.`artikelgroup_id` = `artikel_group`.`id` inner join `fotografer` on `artikel_group`.`fotografer_id` = `fotografer`.`id` inner join `order_has_artikelgroup` on `order_has_artikelgroup`.`artikelgroup_id` = `artikel_group`.`id` inner join `order` on `order`.`id` = `order_has_artikelgroup`.`order_id` inner join `customer` on `order`.`customer_id` = `customer`.`id`"
the query result sql query in btowser use php framework codeigniter
name | email | customer | invoice id| lekto | lekto@gmail.com | edwin | 11 | lekto | lekto@gmail.com | risa | 12 | lekto | lekto@gmail.com | edwin | 13 | heko | heko@gmail.com | pae | 15 | heko | heko@gmail.com | edwin | 16 |
how group field like
name | email | customer | invoice id| lekto | lekto@gmail.com | edwin | 11 | | | risa | 12 | | | edwin | 13 | heko | heko@gmail.com | pae | 15 | | | edwin | 16 |
please show query this
odd question, if need in mysql use user variables set name
, email
column '' (empty string) subitems in list.
demo fiddle or e.g.
select if(@tname!= name, if(@'tname':= name, name,name) , '' ), if(@temail!= email, if(@'temail':= email, email ,email) , '' ), customer, invoice_id, /* blah blah blah */ tables join (select @'tname':='', @'temail':='') t on 1=1 /* blah blah blah */
i provide join (select @'tname':='') t on 1=1
re-initialize user variable in case can't control them.
Comments
Post a Comment