Sam Smith wrote:
> Using MySQL 4.1 and the built in scripting is it possible to write a script
> that checks to see if a table exists and then branches one way and branches
> another if it doesn't?
>
> I've been trying all sorts of combinations but nothing works for me. I was
> thinking of running a select * from the table that I am interested in and if
> it returned a null then that would mean it would not exist but I do not know
> how to write this in SQL script.
>
> Is there anyone out there that can help me or at least point me in the right
> direction? TIA.
>
> ---
> Sam
>
>
you would not receive a null from such a query, you would receive an ERROR.
try
select table_name from information_schema.tables
where table_schema ='someschemaname'
and table_name ='yourtablename';
now, if 0 rows returned, it does not exist else it does.
--
Michael Austin
Database Consultant
Domain Registration and Linux/Windows Web Hosting Reseller
http://www.spacelots.com