Page 1 of 1

how to add OR conditions to where clause?

Posted: Thu 16 Sep 2010 11:54
by brace
AddWhere works perfectly for adding AND conditions.

how to simply add any condition?

let's say I have

Code: Select all

select * from table
where id > 5
let's say I want to add "or age > 30"

how can I do without explcitly doing:

Code: Select all

msquery1.sql[1] := msquery1.sql[1] + ' or age > 30'
???

The above approach forces me to keep manually track at which line the WHERE clause ends, I mean in practice what I do is

Code: Select all

const
  POS_WHERE: integer := 34 // hardcoded, need to manually check every time I change SQL code

msquery1.sql[POS_WHERE] := msquery1.sql[POS_WHERE] + ' or age > 30'

Posted: Fri 17 Sep 2010 07:30
by AndreyZ
Hello,

We don't have any equivalent of the AddWhere procedure for OR conditions. You should do it manually.