Home > database >  A SQL statement, test for a long time
A SQL statement, test for a long time

Time:10-10

The table has a field in a
Table b field b
All field data is letter

Now I want to find out in the table a field a meet: in b all records with a beginning and end with a

I like to write, record the lookup is not complete, there are omissions,
don't know what is going onSELECT a. * FROM a, b WHERE a.a LIKE CONCAT (b.b, "%") AND a.a LIKE CONCAT (" % ", b.b)

In the effect of the kind of writing is still the same, there is a miss, can't the
SELECT a. * FROM a JOIN b ON a.a LIKE CONCAT (" ", b.b, "%") AND a.a LIKE CONCAT (" % ", b.b, "")

Beg your answer, thank you

CodePudding user response:

Should not be to like a good understanding with b.b
?SELECT * FROM test_a a, test_b b WHERE b.k ey LIKE CONCAT (a.k ey, '%', a.k ey)

CodePudding user response:

references a monkey's reply: 1/f,
should not be to like a good understanding with b.b
?SELECT * FROM test_a a, test_b b WHERE b.k ey LIKE CONCAT (a.k ey, '%', a.k ey)

With you that this is still the same effect, such as zhangshan which satisfies both sides haven't found out is the name of the word, if it is zhangxiaoshan is found out

CodePudding user response:

Post the statement there is a big problem, I wrote two b.b is the value of the same, so the only zhangyizhang just meet, had to check in two steps, first check to the right, with a result set to perform check on the left, but the efficiency is too low, how to do

CodePudding user response:

reference zhoufuguang reply: 3/f
posts the statement there is a big problem, I wrote two b.b is the value of the same, so the only zhangyizhang just meet, had to check in two steps, first check to the right, with a result set to perform check on the left, but the efficiency is too low, how to do


Logic has changed you such a beginning of any arbitrary end a
SELECT a. *, * FROM b. test_a a, test_b b, test_a c WHERE b.k ey LIKE CONCAT (c.k ey, '%', a.k ey) so as to optimize depends on you to write SQL and the environment

CodePudding user response:

 select Anderson d from a where Anderson d in (select b.i d from b where b.i d like 'a' a %) 
  • Related