MySQL Lists are EOL. Please join:

List:General Discussion« Previous MessageNext Message »
From:Jim Winstead Date:May 28 2004 4:08am
Subject:Re: query to see if db exists...........mysql_query( myQuery)
View as plain text  
On Thu, May 27, 2004 at 03:59:46PM -0400, Bono, Saroj AA R62 wrote:
> I am going to use mysql_query() and want to find out if a certain
> database  exists. If  mysql_real_connect() fails there are many errors
> that could account for this. The database may exist , and I cant take
> the error returned from the failed  query to mean the db isnt there and
> should be created. So what sort of query can I use to see whether the db
> exists? I thought of "USE myDb" but once again a failed mysql_query cant
> rule out other factors that can cause the failure. Any suggestions? 

You could use "SHOW DATABASES LIKE 'myDb'".

  http://dev.mysql.com/doc/mysql/en/Show_database_info.html

Jim Winstead
MySQL AB
Thread
query to see if db exists...........mysql_query( myQuery)Saroj AA R62 Bono27 May
  • Re: query to see if db exists...........mysql_query( myQuery)Jim Winstead28 May
Re: query to see if db exists...........mysql_query( myQuery)Stephen E. Bacher28 May