Jump to content


Photo

Table exists


  • Please log in to reply
4 replies to this topic

#1 alecjw

alecjw
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts
  • LocationHatfield, Herts, UK

Posted 06 August 2006 - 10:13 PM

Is there a MySQL query which returns whether a table exists or not?

#2 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 06 August 2006 - 10:51 PM

"SHOW TABLES" will return rows containing the table names in the database.
Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 07 August 2006 - 04:42 AM

And you can add a "LIKE" clause to show tables as well, and check for any rows returned.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#4 alecjw

alecjw
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts
  • LocationHatfield, Herts, UK

Posted 07 August 2006 - 09:15 AM

So would that query return array("table1_name","table2_name") etc?

#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 07 August 2006 - 12:38 PM

If you ask for an array back, then yes... it will return a recordset, with a single column.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users