How can I check if a MySQL table exists with PHP?

前端 未结 12 1668
小鲜肉
小鲜肉 2020-12-02 13:08

As simple in theory as it sounds I\'ve done a fair amount of research and am having trouble figuring this out.

How can I check if a MySQL table exists and if it does

12条回答
  •  旧巷少年郎
    2020-12-02 14:00

    mysql_query("SHOW TABLES FROM yourDB");
    //> loop thru results and see if it exists
    //> in this way with only one query one can check easly more table 
    

    or mysql_query("SHOW TABLES LIKE 'tblname'");

    Don't use mysql_list_tables(); because it's deprecated

提交回复
热议问题