eption in my program. I thought there should
> be an easy way using SQL to determine if a temporary table exists or
> not.
Why not "CREATE TEMPORARY TABLE IF NOT EXISTS ..."? If you really need
to know whether the table existed before or not, that command will
return a warning if it
should
> be an easy way using SQL to determine if a temporary table exists or
> not.
Why not "CREATE TEMPORARY TABLE IF NOT EXISTS ..."? If you really need
to know whether the table existed before or not, that command will
return a warning if it was there already.
htt
eate it.
I suppose could count the rows in Tablex and it would throw an exception if
the table did not exist . But I really didn't want to resort to trapping an
exception in my program. I thought there should be an easy way using SQL to
determine if a temporary table exists or not.
Mike
Try drop table if exists Tablex;
On Fri, Nov 21, 2008 at 9:53 AM, mos <[EMAIL PROTECTED]> wrote:
> How can I determine if a temporary table exists? Normally I use something
> like:
>
> create temporary table Tablex like Table1;
> show tables like "Tablex";
>
&g
How can I determine if a temporary table exists? Normally I use something like:
create temporary table Tablex like Table1;
show tables like "Tablex";
but the Show Tables never displays any rows for a temporary table even
though the temporary Tablex exists. (All in same thread).
So
> Maybe you could use
>
> SHOW TABLES LIKE 'your_table';
That's a great idea, I just tried it in several ways, like:
IF EXISTS (SHOW TABLES LIKE 'cfgbiz') THEN
SELECT siacnotifyto FROM cfgbiz
ELSE
SELECT '' as siacnotifyto
END IF;
-and-
select IF((SHOW TABLES LIKE 'cfgbiz'),notifyto
On Thursday 06 October 2005 10:57 am, Ryan Stille wrote:
> I am converting some code from MSSQL to MySQL. In one place I need to
> have a conditional query depending on if a table exists or not. There
> are different versions of this application and the table only exists in
> some of
Ryan Stille wrote:
If I have to, I could resort to doing another query in my application
(SHOW TABLES) and seeing if my table was returned in that list. But I
was hoping for a more elegant way to do it, within the single query.
Maybe you could use
SHOW TABLES LIKE 'your_table';
--
Keith
> If 'SHOW COLUMNS FROM tablename' returns error 1146 (42S02), the
> table doesn't exist.
This causes my application (ColdFusion) to throw an exception.
If I have to, I could resort to doing another query in my application
(SHOW TABLES) and seeing if my table was returned in that list. But I
wa
Ryan,
>I am converting some code from MSSQL to MySQL. In one place I need to
>have a conditional query depending on if a table exists or not. There
>are different versions of this application and the table only exists in
>some of them. Here is how it was done in MSSQL:
If '
I am converting some code from MSSQL to MySQL. In one place I need to
have a conditional query depending on if a table exists or not. There
are different versions of this application and the table only exists in
some of them. Here is how it was done in MSSQL:
IF OBJECT_ID('cfgbiz') I
this (old as alabama)
application. They refuse to support newer versions of MySQL.
- Original Message - From: "Eric Bergen" <[EMAIL PROTECTED]>
To: "Jim McAtee" <[EMAIL PROTECTED]>
Cc:
Sent: Monday, May 02, 2005 11:31 AM
Subject: Re: Determining if a table exists
riginal Message - From: "Eric Bergen" <[EMAIL PROTECTED]>
To: "Jim McAtee" <[EMAIL PROTECTED]>
Cc:
Sent: Monday, May 02, 2005 11:31 AM
Subject: Re: Determining if a table exists
I don't remember what commands are available in 3.21 but try these
show tables like &
is 3.23.x. Dictated by this (old as alabama)
application. They refuse to support newer versions of MySQL.
- Original Message -
From: "Eric Bergen" <[EMAIL PROTECTED]>
To: "Jim McAtee" <[EMAIL PROTECTED]>
Cc:
Sent: Monday, May 02, 2005 11:31 AM
Subject: R
I don't remember what commands are available in 3.21 but try these
show tables like 'table_name';
then check mysql_num_rows on the result.
describe table;
check mysql_num_rows
show tables;
then pick out the table name;
3.21 is old as alabama (forrest gump) it's time for an upgrade :)
Jim McAtee wro
We're running an application that creates table names in a numeric
sequence. For example:
jst998_foo
jst998_bar
jst999_foo
jst999_bar
jst0001000_foo
jst0001000_bar
jst0001001_foo
jst0001001_bar
I need to write a maintenance app that first needs to determine the
numeric range of
At 3:37 PM -0500 9/19/03, Don Read wrote:
On 19-Sep-2003 Don Read wrote:
On 19-Sep-2003 Dan Anderson wrote:
I am trying to make my PHP script autodetect when a table in a mySQL
database exists, and when it doesn't, create it.
function tableexists($tbl) {
$res = @mysql_query("SELECT 1
On 19-Sep-2003 Don Read wrote:
>
> On 19-Sep-2003 Dan Anderson wrote:
>> I am trying to make my PHP script autodetect when a table in a mySQL
>> database exists, and when it doesn't, create it.
>>
>
>
> function tableexists($tbl) {
> $res = @mysql_query("SELECT 1 FROM $tbl");
> retur
On 19-Sep-2003 Dan Anderson wrote:
> I am trying to make my PHP script autodetect when a table in a mySQL
> database exists, and when it doesn't, create it.
>
function tableexists($tbl) {
$res = @mysql_query("SELECT 1 FROM $tbl");
return ($res ? true : false);
}
Regards,
--
Don Rea
> Is there some way to do something like:
>
> SELECT * FROM tables WHERE name = "table_name";
>
> And get a result I could test for truth, and thus run my script?
Show tables like 'table_name';
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:htt
* Dan Anderson
> I am trying to make my PHP script autodetect when a table in a mySQL
> database exists, and when it doesn't, create it.
>
> Is there some way to do something like:
>
> SELECT * FROM tables WHERE name = "table_name";
>
> And get a result I could test for truth, and thus run my scrip
I am trying to make my PHP script autodetect when a table in a mySQL
database exists, and when it doesn't, create it.
Is there some way to do something like:
SELECT * FROM tables WHERE name = "table_name";
And get a result I could test for truth, and thus run my script?
Thanks in advance,
Da
Sent: Tuesday, April 23, 2002 10:38 AM
Subject: Re: Checking if a table exists?
> At 04:58 AM 4/23/2002, you wrote:
> >Hi!
> >
> >How do check if a certain table exists? I have to know if
> >the table exists and then make a query in that
> >table. I mean to use it in a
At 04:58 AM 4/23/2002, you wrote:
>Hi!
>
>How do check if a certain table exists? I have to know if
>the table exists and then make a query in that
>table. I mean to use it in a function so the SHOW TABLES
>is not an option...
>
>I have tried the "sysobjects&quo
Hi!
How do check if a certain table exists? I have to know if
the table exists and then make a query in that
table. I mean to use it in a function so the SHOW TABLES
is not an option...
I have tried the "sysobjects" solution but it comes back with:
table 'lve.sysobjects' do
ple.
>
> You have written the following:
>
> On Thu, Mar 28, 2002 at 04:30:25PM -0600, BD wrote:
> > At 06:20 AM 3/28/2002, you wrote:
> > >>
> > >> What is the fastest way to check if a table exists?
> > >> Do a select and catch the error?
> >
At 06:20 AM 3/28/2002, you wrote:
>On 27-Mar-2002 Ken Anderson wrote:
> >
> >
> >
> >
> >
> > What is the fastest way to check if a table exists?
> > Do a select and catch the error?
> > Try to create the table, and catch the error?
>
On 27-Mar-2002 Ken Anderson wrote:
>
>
>
>
>
> What is the fastest way to check if a table exists?
> Do a select and catch the error?
> Try to create the table, and catch the error?
> Other options?
> Thanks,
> Ken
Yes, in php:
function tableexist
>
> show tables like "tablename";
>
> It'll either give an empty set, or return the tablename.
>
> --
> sh
>
> On Wed, 2002-03-27 at 14:29, Ken Anderson wrote:
> >
> >
> >
> >
> >
> > What is the fastest way to check if a ta
-03-27 at 14:29, Ken Anderson wrote:
>
>
>
>
>
> What is the fastest way to check if a table exists?
> Do a select and catch the error?
> Try to create the table, and catch the error?
>
What is the fastest way to check if a table exists?
Do a select and catch the error?
Try to create the table, and catch the error?
Other options?
Thanks,
Ken
sql,query
-
Before posting, please check:
http
]
: Subject: Table Exists
:
: What is the easiest way to check if a table exists in the current
: database? I checked the documentation, and couldn't find anything (but
: maybe I missed it).
:
:
e), or DESCRIBE tablename
- Jonathan
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 14, 2001 8:34 AM
To: [EMAIL PROTECTED]
Subject: Table Exists
What is the easiest way to check if a table exists in the current
database? I checked the doc
Mysql>show tables;
Would be the easy way
Thank you,
Todd Williamsen, MCSE
home: 847.265.4692
Cell: 847.867.9427
-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, December 14, 2001 10:34 AM
To: [EMAIL PROTECTED]
Subject: Table Exists
What is
What is the easiest way to check if a table exists in the current
database? I checked the documentation, and couldn't find anything (but
maybe I missed it).
Glen
-
Before posting, please check:
http://www.mysq
35 matches
Mail list logo