Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>If your content always start with tags( etc.)</strong></p> <p>try this:</p> <pre><code>SELECT * from table WHERE colmn_name REGEXP '&gt;[^&lt;]*mytext'; </code></pre> <p><strong>Another way is to use <code>strip_tags</code> — Strip HTML and PHP tags from a string</strong></p> <pre><code>&lt;?php $text = '&lt;p&gt;Test paragraph.&lt;/p&gt;&lt;!-- Comment --&gt; &lt;a href="#fragment"&gt;Other text&lt;/a&gt;'; echo strip_tags($text); echo "\n"; // Allow &lt;p&gt; and &lt;a&gt; echo strip_tags($text, '&lt;p&gt;&lt;a&gt;'); ?&gt; </code></pre> <p>Output of above code:</p> <pre><code>Test paragraph. Other text &lt;p&gt;Test paragraph.&lt;/p&gt; &lt;a href="#fragment"&gt;Other text&lt;/a&gt; </code></pre> <p><strong>Warning</strong>:: <code>Because strip_tags() does not actually validate the HTML, partial or broken tags can result in the removal of more text/data than expected.</code></p> <p>You should put the html code in a variable, let's say <code>$html_input</code></p> <pre><code>$html_input= "'&lt;p&gt;text between tag 'p'&lt;/p&gt;&lt;span&gt;text between 'span'&lt;/span&gt;'"; $stripped_html = strip_tags($html_input); // Now insert it into the table `text` INSERT INTO `text` VALUES (1, $striped_html); </code></pre> <p><strong>Purely <code>MYSQL</code> way:</strong></p> <pre><code>CREATE FUNCTION `strip_tags`($str text) RETURNS text BEGIN DECLARE $start, $end INT DEFAULT 1; LOOP SET $start = LOCATE("&lt;", $str, $start); IF (!$start) THEN RETURN $str; END IF; SET $end = LOCATE("&gt;", $str, $start); IF (!$end) THEN SET $end = $start; END IF; SET $str = INSERT($str, $start, $end - $start + 1, ""); END LOOP; END; mysql&gt; select strip_tags('&lt;span&gt;hel&lt;b&gt;lo &lt;a href="world"&gt;wo&lt;&gt;rld&lt;/a&gt; &lt;&lt;x&gt;again&lt;.'); +----------------------------------------------------------------------+ | strip_tags('&lt;span&gt;hel&lt;b&gt;lo &lt;a href="world"&gt;wo&lt;&gt;rld&lt;/a&gt; &lt;&lt;x&gt;again&lt;.') | +----------------------------------------------------------------------+ | hello world again. | +----------------------------------------------------------------------+ 1 row in set </code></pre> <p>Reference: <a href="https://stackoverflow.com/questions/7654436/what-is-the-mysql-query-equivalent-of-php-strip-tags">Stackoverflow</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload