RE: [PHP-DB] Does MySQL support tables with numbers in them?

From: Date: Tue, 08 Aug 2000 18:50:49 +0000
Subject: RE: [PHP-DB] Does MySQL support tables with numbers in them?
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-1865@lists.php.net to get a copy of this message
The problem with your CREATE TABLE statement is not with the numbers in the table name, but with the MONEY data type that you are attempting to use. Although the MONEY data type is available in mSQL, it is not available in MySQL (see section 21.1.3 of the MySQL manual: 'How mSQL 2.0 SQL syntax differs from MySQL'). To get the equivalent of the MONEY data type, use DECIMAL(12,2). For example: --- snip --- Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 3 to server version: 3.22.29 Type 'help' for help. mysql> CREATE TABLE 555555_person_num (person_num int primary key, quantity int, cost MONEY); ERROR 1064: You have an error in your SQL syntax near 'MONEY)' at line 1 mysql> CREATE TABLE person_num (person_num int primary key, quantity int, cost MONEY); ERROR 1064: You have an error in your SQL syntax near 'MONEY)' at line 1 mysql> CREATE TABLE person_num (person_num int primary key, quantity int, cost decimal(12,2)); Query OK, 0 rows affected (0.01 sec) mysql> CREATE TABLE 555555_person_num (person_num int primary key, quantity int, cost decimal(12,2)); Query OK, 0 rows affected (0.01 sec) --- snip --- Hope this helps! Eric Dennis Manager - Internet Services Comtelligence, LLC (http://www.comtelligence.net) -----Original Message----- From: Miles Thompson [mailto:milesthompson@sprint.ca] Sent: Tuesday, August 08, 2000 11:09 AM To: Dave; php-db@lists.php.net Subject: Re: [PHP-DB] Does MySQL support tables with numbers in them? Check the MySQL docs to make certain, but this might solve the problem if $a = "55555" is a string rather than a number. Also, is the syntax correct for the CREATE TABLE statement? Do you need to indicate the size of the int's, deciaml places for money? (I'm not looking it up, and I'm no authority on create table statements, they're usually done once, then not tampered with for ages. <g>) HTH - Miles Thompson Dave wrote: > Can I create a table that has a number as part of its name: > > $a = 555555; > > $sql="CREATE TABLE " . $a . "_person_num (person_num int primary key, > quantity int, cost MONEY)"; > > The above sql returns an error. Is there a way around this? > > Thanks, > Dave > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#1865) next »