Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

i have 2 tables areas2013

row_id | area              |teamleader
1      |  1234-Asia        |   Joe 
2      |  12345-Europe     |   Juan  
3      | 123456-UK         |   Ple 

and f12

row_id| eacode
1     | 1234
2     | 12345
3     | 1234

as you can see i want to match the eacode and area using like% and count how many eacode.

i want something like this in php

eacode| area | count | teamleader 
1234  | Asia  |   2    |  Joe
12345 | Europe|   1    |  Juan

sorry for my bad english

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
144 views
Welcome To Ask or Share your Answers For Others

1 Answer

SELECT eacode, substr(area, locate('-', area) + 1) area, count(*) `count`, teamleader
FROM f12
JOIN areas2013 ON area like CONCAT(eacode, '-%')
GROUP BY eacode

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...