1

我有一个数据表如下:

过滤器表

**id    filter**    
4638    Aabe    
4639    Aaby    
4640    Aadl    
4641    Aaga    
4642    Aake

姓氏表

**surnames**    
Aaberge    
Aabehut    
Aabyuti    
Aabytis    
Aadlit    
Aagastha    
Aaker

我正在尝试编写一个内部查询以从表中检索surnames匹配过滤器的计数filter

以下是我基于单独的选择语句的内容

  1. select * from filter
  2. select count(*) from surnames where last_name like 'Aabe%' or last_name like 'Aaby%' group by last_name;

由于记录数很大,如何为此条件编写内部查询?

4

1 回答 1

0
select *,
COUNT(*) from surnames join filters 
on SURNAMES.last_name LIKE CONCAT(filters.filter,'%') 
where filters.id > 4215 
group by last_name
于 2015-10-15T21:39:25.767 回答