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
Re: create tmp table of column list of a table for future use
I believe it has to be like this: create table column_list (MYTABLE_NAME DESC); Thanks! -Alex Big Al Behrens E-mail: [EMAIL PROTECTED] Urgent E-mail: [EMAIL PROTECTED] (Please be brief!) Phone: 651-482-8779 Cell: 651-329-4187 Fax: 651-482-1391 ICQ: 3969599 Owner of the 3D-Unlimited Network: http://www.3d-unlimited.com Send News: [EMAIL PROTECTED] - Original Message - From: hong chen [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, April 05, 2002 4:13 PM 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
RE: create tmp table of column list of a table for future use
-Original Message- From: hong chen Sent: Friday, April 05, 2002 5:32 PM To: 'Alex Behrens' Subject: RE: create tmp table of column list of a table for future use No luck. Oracle and Sql Server have system tables to check. 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 create table column_list ( ATTRIBUTES desc); ERROR 1064: You have an error in your SQL syntax near 'desc)' at line 1 mysql create table column_list (desc ATTRIBUTES); ERROR 1064: You have an error in your SQL syntax near 'desc ATTRIBUTES)' at line 1 mysql select Field from (desc ATTRIBUTES); ERROR 1064: You have an error in your SQL syntax near 'desc ATTRIBUTES)' at line 1 mysql -Original Message- From: Alex Behrens [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 5:24 PM To: hong chen; [EMAIL PROTECTED] Subject: Re: create tmp table of column list of a table for future use I believe it has to be like this: create table column_list (MYTABLE_NAME DESC); Thanks! -Alex Big Al Behrens E-mail: [EMAIL PROTECTED] Urgent E-mail: [EMAIL PROTECTED] (Please be brief!) Phone: 651-482-8779 Cell: 651-329-4187 Fax: 651-482-1391 ICQ: 3969599 Owner of the 3D-Unlimited Network: http://www.3d-unlimited.com Send News: [EMAIL PROTECTED] - Original Message - To: [EMAIL PROTECTED] Sent: Friday, April 05, 2002 4:13 PM 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
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- From: hong chen [mailto:[EMAIL PROTECTED]] 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
RE: create tmp table of column list of a table for future use
-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
RE: create tmp table of column list of a table for future use
Problem is I'm accessing mysql through scripting against a table that may or may not have ID field, select count(*) from (desc ATTRIBUTES) where Field ='ID'; if count(*) 0 then select ID from ATTRIBUTES; else do something else; end if; -Original Message- From: Gurhan Ozen [mailto:[EMAIL PROTECTED]] Sent: Friday, April 05, 2002 5:57 PM To: hong chen Subject: RE: create tmp table of column list of a table for future use SHOW CREATE TABLE ... syntax will show you whether or not the field name is there.. Gurhan - 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