Requirement one:
When querying, display the user's mobile phone number (such as 1331234567) as 133***4567
This is an interview question I saw in the exchange group. I am very disgusted to process the data directly during the query. Can it be processed after the query is out, but the interview question requirements are like this.
Here, simply write two table association queries, and then process and display the mobile phone number
select a.uid,a.username, concat(left(a.cellphone_number,3),'****',right(a.cellphone_number,4)) as mobile_ ,b.gender,b.age from front_u a JOIN front_u_tends b where a.uid = b.uid
query result
Requirement two:
Tag requirements, that is, the tag contains the tag 77
Two ideas:
The first one, use find_in_set (the way I recommend)
用法: WHERE FIND_IN_SET(77,tag)
The second, use the like statement (this method has loopholes and is not recommended)
用法: WHERE tag like "%77,%"
The original three interview questions are as follows:
sql written by me:
select ba.*,fd.*, concat(left(ba.mobile,1),'+++++++++',right(ba.mobile,1)) as mobile_ from baomings ba join fd_firm_baoming fd on ba.id = fd.baoming_id where find_in_set(77,fd.tag) and fd.td_type <> 0