What is the SQL statement for checking the existance of a table in a schema?
I don't really know but you could do a SHOW TABLES; and see if the table is in that list. Hmm, I wonder if you can do a SELECT on TABLES.
this works very well:
select count(*) from table where 1 = 0
You could use the PHP function mysql_list_tables() with mysql_tablename() in order to populate an array and then use in_array() to test if the table exists.
http://www.phpbuilder.com/manual/function.mysql-list-tables.php http://www.phpbuilder.com/manual/function.mysql-tablename.php http://www.phpbuilder.com/manual/function.in-array.php
Or, you could use mysql_select_db() as normal and see if the DB select returns true or false.
Hope this helps.
-Rich
Here is the statement for Microsoft SQL Server
SELECT OBJECT_ID('Object Name') AS OBJECT_ID
This will return some huge number or NULL.
Thanks to all. I'll try when I get to work tomorrow morning. By the way, I am using mySQL
With mysql you can use this sql statement: show tables like "table_name";
This return an empty set or the tablename. Bye