how to add OR conditions to where clause?

Discussion of open issues, suggestions and bugs regarding SDAC (SQL Server Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
Posts: 213
Joined: Wed 14 Feb 2007 08:26

how to add OR conditions to where clause?

Post by brace » Thu 16 Sep 2010 11:54

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

  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'


Post by AndreyZ » Fri 17 Sep 2010 07:30


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

Post Reply