Home > Back-end >  MySQL fuzzy query
MySQL fuzzy query

Time:09-20

Table at the moment, I have three tables, school (school), professional table (profession) and intermediate table (gaokao), including professional watch and middle part of the field are as follows:
-- -- -- the middle table

,
professional table

Now I have such a query, enter the school name, according to the professional table to match spname field proname to the middle of the table?

Select *
The from mybatis. School s,
Mybatis. Profession p
Mybatis. Gaokao g
Where s.s cid=g.s cid
And g.s pname=p.p roname
And s.n ame='Beijing university'


Difficulty is, for example a clause in the middle table spname "economics class (economics, finance, international economy and trade, insurance, risk management and insurance), finance, resource and environmental economics)" data, how to look for in the professional table to economics, finance, international economy and trade, such as the professional? That is how to modify the above my query, I hope you can be glad,

CodePudding user response:

Select *
The from mybatis. School s,
Mybatis. Profession p
Mybatis. Gaokao g
Where s.s cid=g.s cid
And g.s pname like concat (" % ", p.p roname, "%")
And s.n ame='Beijing university'
  • Related