Note that there are some explanatory texts on larger screens.

plurals
  1. POMySQL tag search
    primarykey
    data
    text
    <p>I have a table with images and tags in it (called <code>tbl_images</code>)</p> <pre><code>image_file image_tags ---------- ---------------------------- test.png tag1 another_tag tag2 hi.jpg tag9 tag1 another_tag qwerty </code></pre> <p>How would I do it so that:</p> <ul> <li>searching 'another' returns nothing</li> <li>searching 'tag1' returns the test.png row</li> <li>searching 'tag1 another_tag' returns the test.png row</li> <li>searching 'qwerty tag2' returns nothing</li> </ul> <p>?</p> <p>As in, the ability to search using the <em>full</em> tag name and to search multiple tags at the same time if they all occur in the same image_tags field in the same row. Note:-</p> <ul> <li>I'm only searching within one field</li> <li>Its being done with a PHP search input (retrieved in <code>$_GET['search_terms']</code>)</li> <li>I can't do <code>LIKE '%tag9%</code> because tag9 could appear in a larger tag, such as <code>Atag98</code>, and as I said I would only like the <em>exact</em> tag match.</li> <li>I can't do <code>LIKE ' tag9 '</code> (note the space before and after,) because tag9 may appear at the beginning of the image_tags field (where there is no space, so there would be no match)</li> <li>I can't do <code>LIKE 'tag9 another_tag'</code> because I don't know if another_tag comes after tag9, similarly I can't do <code>LIKE 'tag9%another_tag'</code> for the same reason; also tag9 could be part of a larger tag (as mentioned previously.)</li> </ul> <p>Also, is fulltext search appropriate for this? And if so, could you provide an example please?</p> <p>A tricky problem (for me anyway;) any help would be greatly appreciated.</p>
    singulars
    1. This table or related slice is empty.
    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.
 

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