MySQL 上的 LIKE 函数未提取相似词

LIKE function on MySQL not picking up similar words

我目前正在使用 db-fiddle.com 练习我的 SQL 代码。

我有两个 table。

'Customers':

Customers_id PracticeName Location PracticeType Subref
1 Hermitage Vets Essex Farm P030022
2 West End Vets Edinburgh Companion P030023

'Samples':

Samples_id Subref SampleType det FAM VIC Gel_result
1 P030022_1 SWAB MHYPCR 38.72 35.00 null
2 P030022_2 SWAB MHYPCR 34.23 30.05 null
3 P030022_3 SWAB MHYPCR 34.00 29.99 null
4 P030022_4 SWAB MHYPCR 30.00 37.10 null

(Samples 中有更多 subref 示例和更多列,但我不想让页面混乱。)

可以有多个样本作为一个子参考的一部分,这就是为什么我将它们设为两个 table 并使用下划线来定义每个样本的结果。

我希望能够看到属于 PracticeName 旁边的 Subref 的所有样本。所以最终结果是示例 table 但附加了 PracticeName 列。

抱歉,如果这不是格式化事物的最佳方式,但我是一个非常新的初学者。

我尝试了这两个代码,它们显然已执行但结果中没有任何显示:

SELECT * FROM Customers, Samples WHERE Customers.Subref LIKE (Samples.Subref + '%');

SELECT * FROM Customers, Samples WHERE Customers.Subref LIKE concat (Samples.Subref, '%');

我也尝试创建另一个 table 来执行多对多查询,但再次执行但没有结果:

  Customers_id INT UNSIGNED NOT NULL
  , Samples_id SMALLINT UNSIGNED NOT NULL
  , PRIMARY KEY pk_Customers2Samples (Customers_id, Samples_id)
);
WHERE Customers.Subref like 'Samples.Subref%';

我不确定我做错了什么。

如有任何建议,请多多指教。

查看你的数据样本.. 由于 _n 最后的代表你应该使用逆 (匹配来自客户的字符串 + % 喜欢样本中的字符串)

SELECT * 
FROM Customers
INNER JOIN Samples ON  Samples.Subref LIKE concat (Customers.Subref, '%')

您的数据中包含更多聊天的示例字符串尊重客户的价值然后不能计算..相反的应该工作