lcVillkor1 = "table.numbers > 1"
SELECT * FROM table WHERE lcVillkor1 ORDER BY table.numbers
I got the error - SQL: WHERE clause is invalid.
I've tried almost every possible combination
"table.numbers > 1", (table.numbers > 1), "(table.numbers > '1')" etc..
Im trying to get some posts (where a number is greater then 1) from a table to print out.
Use & before the variable to expand it:
lcVillkor1 = "table.numbers > 1"
SELECT * FROM table WHERE &lcVillkor1 ORDER BY table.numbers
You can't just put a variable name in a line of code and have it execute. Instead, build up your SQL command as a text variable, and then use something like macro substitution to execute it:
lcVillkor1 = "table.numbers > 1"
lcSql = "SELECT * FROM table WHERE " + lcVillkor1 + " ORDER BY table.numbers"
&lcSql
Also, for future reference, perhaps table and field names close to reserved words - eg "table" and "numbers" - may not be ideal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With