【问题标题】:mysql search part of stringmysql搜索字符串的一部分
【发布时间】:2012-07-16 18:01:41
【问题描述】:

我的数据库中的表中有一个字段,其中包含以下 HTML 代码:

<table class="table_productinfo" border="0" cellpadding="0" cellspacing="0">
<tbody>
<tr><td class="attribute_head"><strong>Ausführung:</strong></td><td><strong>500mm</strong></td></tr>
<tr><td class="attribute_head">Farbe:</td><td>weiß glänzend</td></tr><tr><td class="attribute_head">Material:</td><td>Keramik</td></tr>
<tr><td class="attribute_head">Hersteller:</td><td>antoniolupi</td></tr>
<tr><td class="attribute_head">Serie:</td><td>ALBUM</td></tr>
<tr><td class="attribute_head">Design:</td><td>Prospero Rasulo</td></tr>
<tr><td class="attribute_head">Bemerkung:</td><td>Auch zur Wandmontage geeignet</td></tr>
<tr><td class="attribute_head">Höhe in mm:</td><td>150</td></tr>
<tr><td class="attribute_head">Tiefe in mm:</td><td>500</td></tr><tr><td class="attribute_head">Breite in mm:</td><td>500</td></tr>
<tr><td class="attribute_head">Artikelnummer:</td><td>NLALB</td></tr>
</tbody>
</table>

现在我想通过 php 提交一个搜索字符串:

antoniolupi album prospero

如何才能找到包含此内容的特定行?

我尝试了拆分关键字explode(' ',$keyword) 并查找部分出现的方法,但我无法获得我需要的 sql 查询。

【问题讨论】:

  • mysql在哪里发挥作用?
  • 忘记“我的”,这是一个 sql 的东西 :)

标签: mysql sql substring


【解决方案1】:

在 where 子句中,在您正在搜索的列上使用类似的搜索词。其中 column_name like '%search_term" 之后,您可以加入所有搜索词,具体取决于您是只需要一个匹配还是全部匹配。

【讨论】:

  • 哦,天哪..解决方案非常简单..感谢您的回复!我有一个心理障碍.. 我需要做的就是:在哪里描述 LIKE '%antoniolupi%album%prospero%' 谢谢!!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-04-12
  • 2023-02-02
  • 1970-01-01
  • 2011-08-10
  • 1970-01-01
  • 2021-06-10
  • 1970-01-01
相关资源
最近更新 更多