If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
Hi;
I made a lot of research but I couldnt find what I want. Is there any function in MySQL which detects is there any table called "x" or not? I wnat to detect it and if it doesnt exist a SQL sentence will create a table. How can I do that? (I think a stored procedure can help me but how can I detect the existence of a table?)
How can use it with SQL commands?
I tried something like this:
IF((select count(*)
from information_schema.tables
where table_schema = 'db_name'
and table_name = 'x')=0,CREATE TABLE....)
But it didnt work. I dont want to use a stored procedure. Is there any other way?
Of course if you just want to find out if the table exists (i.e. not create it but produce a list of available tables?) then using the last option is not valid.
If you have MySQL 5+ use the information_schema tables. Definitely the way to go...