Is the IN operator available in Webinator 2.5? If not, is there an easy way to achieve the same effect?
IN operator
IN operator
The SQL in Webinator 2.5 does understand IN. What are you trying to achieve?
John Turnbull
Thunderstone Software
Thunderstone Software
IN operator
I want to retrieve several specific records by using the -unique id hash, something like "select Title, Meta, id from html where id IN(78227130186c6924,516a512811223548)". I haven't tried it yet, just making sure it will work.
IN operator
You would need single quotes around the values, but it will work.
John Turnbull
Thunderstone Software
Thunderstone Software
IN operator
Well I tried it and I get a "garbled time in the function month" error.
IN operator
Ok, I've done a bit more troubleshooting and it looks like the problem has to do with passing a variable through the query string. I'm passing a variable "rid" like so: script?db=db&cmd=list&rid='237841204f4e3428','41122840106a4930'
The script fails with the error above when I try:
<SQL "select Title, Meta, id from html where id IN ($rid)">
But works fine when I hardcode the values:
<SQL "select Title, Meta, id from html where id IN ('237841204f4e3428','41122840106a4930')">
The $rid variable looks fine when I output it, so what am I doing wrong?
The script fails with the error above when I try:
<SQL "select Title, Meta, id from html where id IN ($rid)">
But works fine when I hardcode the values:
<SQL "select Title, Meta, id from html where id IN ('237841204f4e3428','41122840106a4930')">
The $rid variable looks fine when I output it, so what am I doing wrong?
IN operator
An inline variable can only represent a single value, and would not need the single quotes. If you write the query as:
<SQL "select Title, Meta, id from html where id IN (" $rid ")">
it should work, however you do run the risk of SQL injection, and so should validate the value of $rid.
<SQL "select Title, Meta, id from html where id IN (" $rid ")">
it should work, however you do run the risk of SQL injection, and so should validate the value of $rid.
John Turnbull
Thunderstone Software
Thunderstone Software
IN operator
Unfortunately that breaks the whole script. I'm guessing it's the nested double quotes. I tried variations using single quotes but no luck. Note taken on the SQL injection. Any other ideas? Would something like the following work?
script?rid=237841204f4e3428,41122840106a4930
<split "," $rid></split>
<SQL "select Title, Meta, id from html where id IN ($ret)">
script?rid=237841204f4e3428,41122840106a4930
<split "," $rid></split>
<SQL "select Title, Meta, id from html where id IN ($ret)">
IN operator
No, the above wouldn't work. What is the error you were getting with the $rid as a separate component? That should work.
John Turnbull
Thunderstone Software
Thunderstone Software