If i have a SQL statement like below
SELECT * FROM myTable WHERE CID = :vCID AND DataType = :vDataType
And usually i use TQuery to get some data like below
aQuery.ParamByName('vCID').Value := '0025';
aQuery.ParamByName('vDataType').AsInteger := 1;
But how can i ignore the "CID" key to get a SQL like
SELECT * FROM myTable WHERE DataType = :vDataType
I've try the below synctax, but failed
aQuery.ParamByName('vCID').Value := '%';
aQuery.ParamByName('vDataType').AsInteger := 1;
Please help me out, thank you.
The best option is to simply use separate queries:
aQueryBoth.SQL.Text := 'SELECT * FROM myTable WHERE CID = :vCID AND DataType = :vDataType';
...
aQueryBoth.ParamByName('vCID').Value := '0025';
aQueryBoth.ParamByName('vDataType').AsInteger := 1;
aQueryDataType.SQL.Text := 'SELECT * FROM myTable WHERE DataType = :vDataType';
...
aQueryDataType.ParamByName('vDataType').AsInteger := 1;