Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^2: OT - SQL choosing a schema for index tables

by bangor (Monk)
on Aug 28, 2015 at 01:48 UTC ( [id://1140270]=note: print w/replies, xml ) Need Help??


in reply to Re: OT - SQL choosing a schema for index tables
in thread OT - SQL choosing a schema for index tables

Yes but the problem is that these fields have multiple values, and I don't think I can create a usable index on a column that has more than one value.
  • Comment on Re^2: OT - SQL choosing a schema for index tables

Replies are listed 'Best First'.
Re^3: OT - SQL choosing a schema for index tables
by poj (Abbot) on Aug 28, 2015 at 07:16 UTC
    SELECT id from tree_field_index WHERE ( (field='usage' AND name='cider') OR (field='usage' AND name='juicer') ) AND (field='flowering' AND name='spring') AND (field='ripe' AND name='autumn')

    This won't work. The select statement gets applied to each record in turn.You can't have a single record where field='usage' AND field='flowering' so the result will be nothing.

    Which database are you using, and how many records roughly are you dealing with ?

    poj
      Thank you poj, you are of course correct, and my Option 2 will not work as I had hoped - you have saved me some time there. I am using MySQL and in this table there are about 200 rows.

        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

        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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1140270]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (2)
As of 2026-03-17 03:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.