Q: Firebird select data from table a or b I am working on a project which shows HTML documents constructed from a Firebird database. In separate files, I have SQL queries. How can I get data from table a, or b in this case?
For example:
Declare varID int = __docid__;

select fielda, fieldb AS fieldbv from
if(varID = 10) then tableA;
else tableB;


A: You may use stored procedure with parameter varId.
In this procedure get the values from table A and B, check the parameter  and return desired result. Something like:
if (:varId = 10) then
   Select fieldA from tableA where ... into :OutParam;
else
   Select fieldB from tableB where ...into :OutParam;
Suspend;

From your project just call this procedure with param varId.

A: Try this :
select iif(varID = 10 ,fielda, fieldb) AS Value from  then tableA left 
join tableB on tableA.id=tableB.id 


A: You may use EXECUTE STATEMENT to run fully dynamic queries. But if you have only 2 choices, Val's answer is good enough.
