mysql - SQL Select All Record In Each Group (Name, DOB) -


i have table id dob amount receiver_name sender_name settle_fee columns.

sample data

id  dob         amount  receiver_name   sender_name     settle_fee ------------------------------------------------------------------- 1   10-06-1990  100       jose      benn        12 2   12-06-1990  200       jim       mike        12 3   10-06-1990  300       kate      benn        12 4   12-06-1990  100       amy       mike        12 5   10-06-1990  200       alison    benn        12 6   12-06-1990  300       mary      mike        12 

expected result

id  dob         sender_name --------------------------- 1   10-06-1990  benn             |--------amount  receiver_name  settle_fee                   100      jose            12                   300      kate            12                   200      alison          12 2   12-06-1990  mike             |--------amount  receiver_name  settle_fee                   200      jim             12                   100      amy             12                   300      mary            12 

i need data of each sender name.

i tried using group_concat(), but, can take 1024 characters.

so, efficient way achieve scenario.

i can't use pl/sql , no session related values allowed.

i need receiver's name, amount, fee sender_name. efficient way it.

thanks, jose

there solution:

just use order by:

select id, dob,sender, amount,  receiver_name,  settle_fee inputtable order sender,dob; 

in displaying want data, use code (dummy code, javscriptish):

var previoussender=""; while(var row=db.fetch()) {   if(row.sender!=previoussender) {     console.log(id+" "+row.dob+" "+row.sender);     previoussend=row.sender();   } else {     console.log("        |-------"+row.amount+" "+row.receiver_name+" "+row.settle_fee);   } } 

as can see: id random since has no relation dob or sender in model. row counter.


Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -