Home > database > Please save a writing SQL statements
Please save a writing SQL statements
Time:09-24
As shown in the following form: ID NAME Zhang SAN 1
2, dick, and harry3 fifty
XUH SUBJECT 1, 2 Chinese 2, 3 mathematical 1, 2, 3 physical 1, 3 English 1 biological
Want to achieve as follows: XUH NAME SUBJECT 1, 2, zhang SAN, li si Chinese 2, 3 li si, fifty and mathematical 1, 2, 3 zhang SAN, li si, fifty and physical 1, 3 threes, fifty and English Zhang SAN biological 1 The trouble to give directions, thank you!
CodePudding user response:
A comma separated, and then make the connection, and then merge
CodePudding user response:
The select xuh, (the select wm_concat (name) from t1 where instr (xuh, id) & gt; 0) as the name, the subject from t2
CodePudding user response:
The select xuh, wm_concat (name) the name, the subject The from ( Select t2 xuh, t1. Id, t1. Name, t2. Subject The from t2 Join the t1 Where instr (t2) xuh, t1. Id) & gt; 0 The order by t1. Id) tt Group by xuh, subject;
CodePudding user response:
My Oracle database version does not support wm_concat the function, in addition the instr not line? Now can I give an example of is 1, 2, 3, this kind of treatment, if be 1,12,123 such serial number, have a problem with the instr,