Gossamer Forum
Home : Products : DBMan SQL : Discussion :

Search question

Quote Reply
Search question
I am trying to do at simple search in one table by passing 2 arguments in the url, ex. :

href="db.cgi?do=modify_search_results&db=Workorder&t=udf&status=Åben" - and it works just fine!

My problem is that i would like to use the != (not equal) comparison operator for a third argument like this:

href="db.cgi?do=modify_search_results&db=Workorder&t=udf&status=Åben&fk_type_workorder!=2" but the result(s) are exactly the same..

At this point I'm perventing the unwanted results from being viewed on the 'modify_search_results' template by using a 'if' statement, but I'm not happy with this solution.

Any help or comments are highly appreciated.

Anders Poulsen

Quote Reply
Re: [vespa180] Search question In reply to
You can specify the SQL operator for a field "foo" with foo-opt=op, e.g.:


You may have to escape the '!=' in the URL, but that's the idea.
Quote Reply
Re: [jxh] Search question In reply to
Thanks for your help, but i still don get it..

The 2 fields I want to search for is:
  1. 'status' column : must be eq (==) to 'Åben'
  2. 'fk_type_workorder' column : must be ne (!=) to '4'

1. works fine with db.cgi?.....;status=Åben
but db.cgi?....;status=Åben;fk_type_workorder-opt='!='4; does not work, I cant figure out if/how -opt is understood by db.cgi..

Any ideas on what I am doing wrong? Can't find any examples on passing != in the url..

Found this in the documentation, but I do not know how to use in an url:


To negate your queries you can use the not function.

my $cond = GT::SQL::Condition->new('a', '=', '5');


would translate into NOT (a = '5'). You can also do this all on one line like:

print GT::SQL::Condition->new('a', '=', '5')->not->sql;

This returns the sql right away.

Any help highly appreciated

Anders Poulsen
Quote Reply
Re: [vespa180] Search question In reply to
You need to send in 4 arguments to express your two conditions:


Don't let the "=" in "=4" fool you; it merely sets the value on the right-hand side of the SQL expression that ultimately results. The "-opt" sets the operator, which will be '!=' (escaped to %41%3d so as not to be considered part of the next token in the URL; I'm not positive this is necessary but it should work), or '=' (%3d), or any valid SQL comparison operator that you want.
Quote Reply
Re: [jxh] Search question In reply to
Hi jxh.
Thanks for your help so far, but I'm afraid that the problem remains the same.
When I pass:

....;fk_type_workorder=4;fk_type_workorder-opt=%21%3d (the ! operator is %21, not %41)

in the url the result is exactly the same as:


I just spent some time fiddling around with various combinations and found that:


does the trick! I hope I don't find any pitfalls using this method.
Thanks for your time jxh.