Home > database >  How to use mysql to write SQL statements to get the desired results?
How to use mysql to write SQL statements to get the desired results?

Time:11-10


Table A:
Field1 field2
A, b, c, d, e, f (a, d, e, g, k, m
Want to get the following results:
Field3 (intersection of) field4 (and) field5 (the number of intersection) field6 (and set the number of)
A, d, e, a, b, c, d, e, f, g, k, m 3 9

O master! Online etc.!

CodePudding user response:

Table:








CodePudding user response:

End after a c # to me, some of this on the back-end work more convenient

CodePudding user response:

On the first floor is already field1 and field2 split again

CodePudding user response:

This problem, simply write SQL, is certainly can be solved, but a little complicated, and execution efficiency is low, certainly
Suggest modify the table structure, don't need as a condition of associated content, comma-separated list of stored,
This should be a typical many-to-many relationship,
  • Related