-----Original Message-----
From: hong chen 
Sent: Friday, April 05, 2002 5:50 PM
To: 'Gurhan Ozen'
Subject: RE: create tmp table of column list of a table for future use


I am trying to check if a certain column exists before I try to select it from the 
table.
in Oracle or Sql Server I would:

select count(*) from user_tab_columns (or sys_columns) where name='C_NAME';

mysql> desc ATTRIBUTES;
+-------+--------------+------+-----+---------+-------+
| Field | Type         | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+-------+
| NAME  | varchar(255) | YES  |     | NULL    |       |
| VALUE | varchar(255) | YES  |     | NULL    |       |
+-------+--------------+------+-----+---------+-------+
2 rows in set (0.02 sec)
mysql> select count(*) from (desc ATTRIBUTES) where Field ='ID';
ERROR 1064: You have an error in your SQL syntax near 'desc ATTRIBUTES)' at line 1


thanx.




-----Original Message-----
From: Gurhan Ozen [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 05, 2002 5:44 PM
To: hong chen; [EMAIL PROTECTED]
Subject: RE: create tmp table of column list of a table for future use


Are you trying to create a new table with an existing table's structure only
? or with the structure and data? If you just wanna duplicate a table with
the data inside it you can use CREATE TABLE .. SELECT ... syntax. More info
is at: http://www.mysql.com/doc/C/R/CREATE_TABLE.html

IF you just wanna copy the structure, do a SHOW CREATE TABLE on the existing
table and copy and paste its CREATE TABLE syntax to create the new one with
a different name. See more info at:
http://www.mysql.com/doc/S/H/SHOW_CREATE_TABLE.html

Gurhan



-----Original Message-----
 
Sent: Friday, April 05, 2002 5:13 PM
To: [EMAIL PROTECTED]
Subject: create tmp table of column list of a table for future use


mysql> create table column_list (desc MYTABLE_NAME);

ERROR 1064: You have an error in your SQL syntax near 'desc MYTABLE_NAME)'
at line 1


Anyone know how to make something like it?

---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to