Since you havent mentioned the DBMS in which you are facing the issue, I have assumed it to be POSTGRES
SELECT to_regclass('foo');
In Postgres 9.3 or older use a cast to regclass:
SELECT 'foo'::regclass;
If at all your requirement is MYSql then use the below statement:
You can use show tables like this to see if a single table exists:
mysql> show tables like "test1";