How to group field data?

前端 未结 2 1562

I have sql query to show data

\"SELECT
  `artikel`.`foto_naam`,
  `fotografer`.`id`,
  `fotografer`.`name_fotografer`,
  `customer`.`first_name`,
  `customer`.`l         


        
2条回答
  •  心在旅途
    2021-01-24 23:03

    Odd question, but if you REALLY NEED THIS in MySQL then you could use USER VARIABLES to set the Name and email column to '' (empty string) for subitems in the 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 */
    from 
        tables
        join (select @'tName':='', @'tEmail':='') T on 1=1 
    /* blah blah blah */
    

    I provide the join (select @'tName':='') T on 1=1 to re-initialize the user variable just in case you can't control them.

提交回复
热议问题