At 04:58 AM 4/23/2002, you wrote: >Hi! > >How do check if a certain table exists? I have to know if >the table exists and then make a query in that >table. I mean to use it in a function so the SHOW TABLES >is not an option... > >I have tried the "sysobjects" solution but it comes back with: > >table 'lve.sysobjects' doesn't exist. > >Thanks for reading, > >/Bo
Bo, This question came up before. I would try something like "select 1 from mytable limit 0" and if it throws and error, the table doesn't exist. If you are using PHP you can use the @ symbol in front of the mysql call to supress the error message. I suggest using "1" because it is an arbitrary constant and I don't have to know the field name. Someone else came up with the idea of executing "show tables like mytable" and if a row is returned, the table exists. Now I don't know if MySQL can turn off "Show Tables" like it can "Show Databases". If you can turn it off, then the "Show tables ..." won't be a universal solution. Brent _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php