选择记录n次,其中n =出现次数

时间:2014-10-08 15:47:42

标签: mysql

我想选择n次记录,其中n是字符串在字段中出现的次数。

示例:

mytable的:

+--------+------------------------------------+
|   id   |                content             |
+--------+------------------------------------+
|   1    | This string contains two strings.  |
|   2    | This is a string.                  |
|   3    | This does not contain our keyword. |
+--------+------------------------------------+

现在我希望这样一个假设查询的结果与以下结果类似:

/* hypothetical: this won't yield the desired result obviously */
SELECT * FROM mytable WHERE content LIKE "%string%";

+--------+------------------------------------+
|   id   |                content             |
+--------+------------------------------------+
|   1    | This string contains two strings.  |
|   1    | This string contains two strings.  |
|   2    | This is a string.                  |
+--------+------------------------------------+

这甚至可能吗?

由于

0 个答案:

没有答案