I should point out that you could make it work but it would be rather complicated !.
Alternatively you could retain the multiple values and use REGEXP in the SELECT . For example

#!perl use strict; use warnings; use DBI; use Data::Dump 'pp'; my $dbh = get_dbh(); $dbh->do('DROP TABLE IF EXISTS trees'); $dbh->do(" CREATE TABLE trees ( id int(11) NOT NULL, uses TEXT , flowering TEXT, ripe TEXT , PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"); while (<DATA>){ chomp; $dbh->do('INSERT INTO trees VALUES(?,?,?,?)',undef,split ';'); } my $sql = 'SELECT * FROM trees WHERE (uses REGEXP(?)) AND (flowering REGEXP(?)) AND (ripe REGEXP(?))'; my $ar = $dbh->selectall_arrayref($sql,undef,'cider|juice|jelly','spri +ng','autumn'); for (@$ar){ print join ",",@$_,"\n"; } sub get_dbh{ my $database = "test"; my $user = "root"; my $pw = ""; my $dsn = "dbi:mysql:$database:localhost:3306"; my $dbh = DBI->connect($dsn, $user, $pw, { RaiseError=>1, AutoCommit +=>1 } ); return $dbh; } __DATA__ 1;cider perry;spring winter;spring autumn winter 2;perry juice perry;winter autumn; autumn winter 3;jelly;spring autumn;spring autumn 4;cider cooking;spring autumn winter;spring winter

Or you could select the records using the single value fields where possible and then filter them with a perl routine using regular expressions.

poj

In reply to Re^5: OT - SQL choosing a schema for index tables by poj
in thread OT - SQL choosing a schema for index tables by bangor

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.