Query with multiple ands (macros)
Posted: Tue 18 Dec 2012 12:04
Hi,
I have a query like:
SELECT * FROM table_name
WHERE col1 = "123"
AND col2 = "456"
AND col3 = "789"
AND col4 = "101112"
But the users will be able to search by any combination of the columns e.g. col1 and col4 or just
col 3.
Currently using macros I have:
SELECT * FROM table_name
&WHERE
&COL1
&AND1
&COL2
&AND2
&COL3
&AND3
&COL4
but turning on and off this macros in code is a bit messy and as they request more columns
in the query its only going to get worse, is there a better way to handle this?
Thanks
Alex
I have a query like:
SELECT * FROM table_name
WHERE col1 = "123"
AND col2 = "456"
AND col3 = "789"
AND col4 = "101112"
But the users will be able to search by any combination of the columns e.g. col1 and col4 or just
col 3.
Currently using macros I have:
SELECT * FROM table_name
&WHERE
&COL1
&AND1
&COL2
&AND2
&COL3
&AND3
&COL4
but turning on and off this macros in code is a bit messy and as they request more columns
in the query its only going to get worse, is there a better way to handle this?
Thanks
Alex