匹配来自另一个 table 的 'LIKE' 结果的内部查询
Inner query to match 'LIKE' results from another table
我有一个 table 数据如下:
过滤器Table
**id filter**
4638 Aabe
4639 Aaby
4640 Aadl
4641 Aaga
4642 Aake
姓氏 Table
**surnames**
Aaberge
Aabehut
Aabyuti
Aabytis
Aadlit
Aagastha
Aaker
我正在尝试编写一个内部查询来检索 surnames
的计数,该计数与 filter
table
中的过滤器相匹配
以下是我根据单独的 select 语句得出的结果
select * from filter
select count(*) from surnames where last_name
like 'Aabe%' or last_name like 'Aaby%' group by last_name;
由于记录数很大,如何为这种情况编写内部查询?
select *,
COUNT(*) from surnames join filters
on SURNAMES.last_name LIKE CONCAT(filters.filter,'%')
where filters.id > 4215
group by last_name
我有一个 table 数据如下:
过滤器Table
**id filter**
4638 Aabe
4639 Aaby
4640 Aadl
4641 Aaga
4642 Aake
姓氏 Table
**surnames**
Aaberge
Aabehut
Aabyuti
Aabytis
Aadlit
Aagastha
Aaker
我正在尝试编写一个内部查询来检索 surnames
的计数,该计数与 filter
table
以下是我根据单独的 select 语句得出的结果
select * from filter
select count(*) from surnames where last_name like 'Aabe%' or last_name like 'Aaby%' group by last_name;
由于记录数很大,如何为这种情况编写内部查询?
select *,
COUNT(*) from surnames join filters
on SURNAMES.last_name LIKE CONCAT(filters.filter,'%')
where filters.id > 4215
group by last_name