"Alvaro G. Vicario" <kA*****************@terra.es> wrote in message news:<3q*****************************@40tude.net>. ..
*** lawrence escribió/wrote (2 Sep 2004 10:05:00 -0700): Google can't find me a good example of how to use the "if exists"
syntax in MySql. Is it right that to use it this way:
INSERT INTO IF EXISTS tMyTable VALUES("xxlk", "lkjlkjlkjljk")
As far as I know, it's CREATE TABLE the one that accepts a similar syntax:
CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name [(create_definition,...)]
[table_options] [select_statement]
SELECT statements also all the use of EXISTS:
http://dev.mysql.com/doc/mysql/en/EX...ubqueries.html
I wish I knew where to go for definitive answers. The MySql manual
leaves a great deal unanswered. It doesn't say, for instance, that
EXISTS cannot be used with INSERT, so I guess I'll have to experiment.
But if I get a syntax error, I won't know if it is because INSERT
doesn't allow EXISTS, or it does but I wrote it wrong.
How does one, in general, from PHP, test for the existence of a table,
without getting an error message?
You can use mysql_list_tables() and search in the result.
This is a good way to go then. EXISTS is less than useful if I can't
get the info I need about it. Might as well rely on PHP to do all my
testing for me. PHP is much better documented than MySql, anyway,
which makes it easier to experiment with.