【发布时间】:2020-12-07 02:39:10
【问题描述】:
我有两张桌子。 我想计算一个值在其他表中的次数。所以表“sorgente”中的代码在表 contatore 中是不同的,因为我在代码前有后缀“BRANO-”。我尝试使用 LIKE,但它不起作用。
sorgente
| codice | nome |
| 15 | mario |
| 16 | mary |
contatore
| nome_evento | data |
| BRANO-15 | 2020-08-15 |
| BRANO-15 | 2020-08-16 |
| BRANO-16 | 2020-08-14 |
所以查询可能是
SELECT sorgente.codice, count(contatore.nome_evento)
FROM sorgente
JOIN contatore
WHERE contatore.nome_evento LIKE '%-'sorgente.codice
但我有一个错误的结果
【问题讨论】:
标签: mysql sql join count subquery