in reply to Re^2: Dynamic SQL
in thread Dynamic SQL

Actually, it's not too difficult to use the same execute statement:

$SQL = "select name from customers where 1=1"; if ($fl_have_cust_id) { $SQL .= " and custid=?"; push @args, $cust_id; } if ($fl_have_sales_id) { $SQL .= " and salesid=?"; push @args, $sales_id; } $ST = $DB->prepare($SQL); $ST->execute(@args);

We have a hardcoded 1=1 condition so we can just add " and <condition>" to $SQL for each new condition we want.

...roboticus

When your only tool is a hammer, all problems look like your thumb.