To meet this requirement, in the Mysql database string field (permission), the user has multiple mailboxes separated by commas (,). Now, you need to retrieve the list of all members of a mailbox.
Suppose there is a table:
Users (id () AUTO_INCREMENT, (id), (), emails ());
Initialize the table and add some records.
Users (, emails) (, users (, emails )(,);
In Mysql, some fields are of the string type. How do I find records containing some characters?
Method 1
It is easy to implement with %.
For example
Users emails "B .com ";
But this will be the bb@email.com also found out does not meet the needs of
Method 2
Use the mysql string function find_in_set ();
Users find_in_set (, emails );
In this way, you can find all the users with aa@emial.com in the e-mail field.
In this way, we can achieve the expected results and solve the problem!
Note that: Mysql string function find_in_set (str1, str2) returns the index of the position of str1 in str2. str2 must be separated by commas.