Home > database >  Mysql like subqueries
Mysql like subqueries

Time:09-15





There are two tables, table A and table B,

A table, A field called: ID,

B table, there is a field called: current_address,

Now want to be a "like the subquery", namely,

Select * from b where current_address like '% table Anderson D %'

CodePudding user response:

But how to write is correct, there is a great god to ask for advice

CodePudding user response:

Select a. *, * from a to b. a, b, b where biggest urrent_address like concat (' % ', Anderson D, '%');

CodePudding user response:

Two table joins, the condition is to write b table current_address like '% table Anderson D %' with respect to ok

CodePudding user response:

The select biggest urrent_address from A table
Inner join table B on biggest urrent_address like concat (' % ', A table. Id, '%');

CodePudding user response:

Select distinct (biggest urrent_address) from table B
Inner join A table on biggest urrent_address like concat (' % ', A table. Id, '%');

CodePudding user response:

Select * from a, b b. where biggest urrent_address=concat ('/artices/', Anderson, d)

CodePudding user response:


Select * from b where current_address like concat ('/artices/', 'table Anderson D %')
Union all select * from b where current_address like concat (other path/'/', 'table Anderson D %')
Union all select * from b where current_address like concat (other path 2/'/', 'table Anderson D %')
,,,

Delete the like the sign on the left, so that we can use index
  • Related