First poted on reddit, can't link here.
In a database I have, various field. The fields contain search criteria for that respective field e.g.
FOO
FOO|BAR|BAZ
*TEST*|*BLUE*
The | character here means 'or' in SQL. So if the column here was called PROD_TITLE, the SQL where clause for above would be:
where PROD_TITLE = 'FOO'
where PROD_TITLE in ('FOO','BAR','BAZ')
where PROD_TITLE like '*TEST* or PROD_TITLE like '*BLUE'
To complicate things further I have a specific column for free search data, containing key/value pairs (like URL params):
&BAZ=TEST
&BAZ=*TEST*
&ORDERDATE=20200101:2020130
&BAZ=TEST*&ORDERDATE=20200101:2020130
I looked at SQL::Abstract::FromQuery but I don't have this data as a URL param. Is there a clever perl way I can use either SQL::Abstract or SQL::Abstract form to generate a SQL query catering for all where clauses?
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.