joseph Posted October 13, 2007 Share Posted October 13, 2007 CREATE TABLE EMPLOYEE ( E# NUMBER(7) NOT NULL, EFNAME VARCHAR(20), ELNAME VARCHAR(20) ); When I run these sql statements in PhpMyAdmin it does not add E# but changes the EFNAME to EEFNAME. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/73103-how-can-i-create-a-fieldname-having-symbols-in-it-like/ Share on other sites More sharing options...
Tyche Posted October 14, 2007 Share Posted October 14, 2007 You can't use # in MySQL table names # is a reserved character which means from here to the end of the current line is a comment and should be ignored - SO effectively your command becomes CREATE TABLE EMPLOYEE ( E EFNAME VARCHAR(20), ELNAME VARCHAR(20) ); which is why the first field is named EEFNAME as the white space is removed Quote Link to comment https://forums.phpfreaks.com/topic/73103-how-can-i-create-a-fieldname-having-symbols-in-it-like/#findComment-369322 Share on other sites More sharing options...
GingerRobot Posted October 14, 2007 Share Posted October 14, 2007 You should be able to do if you enclose the field name in backticks (`). You'd probably be better off not using the # character however. Quote Link to comment https://forums.phpfreaks.com/topic/73103-how-can-i-create-a-fieldname-having-symbols-in-it-like/#findComment-369350 Share on other sites More sharing options...
joseph Posted October 15, 2007 Author Share Posted October 15, 2007 Thanks Ben. I still cannot create the S# field name I enlclosed them in backticks like `S#` or (`S#`) SQL query: CREATE TABLE EMPLOYEE( `E#` NUMBER( 5 ) NOT NULL , EFNAME VARCHAR( 20 ) , ELNAME VARCHAR( 20 ) ) MySQL said: Documentation #1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'NUMBER(5) NOT NULL, EFNAME VARCHAR(20), ELNAME VARCHAR(20), ' at line 2 I think Tyche is right, maybe it is possible with other SQL applications like SQL server? Quote Link to comment https://forums.phpfreaks.com/topic/73103-how-can-i-create-a-fieldname-having-symbols-in-it-like/#findComment-369814 Share on other sites More sharing options...
Barand Posted October 15, 2007 Share Posted October 15, 2007 I have successfully executed this to create table (MySQL 5.0) and also added and reteived data DROP TABLE IF EXISTS `test3`.`widget`; CREATE TABLE `widget` ( `W#` int(10) unsigned NOT NULL auto_increment, `name` varchar(45) NOT NULL, PRIMARY KEY (`W#`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; Quote Link to comment https://forums.phpfreaks.com/topic/73103-how-can-i-create-a-fieldname-having-symbols-in-it-like/#findComment-369838 Share on other sites More sharing options...
fenway Posted October 15, 2007 Share Posted October 15, 2007 CREATE TABLE EMPLOYEE ( E# NUMBER(7) NOT NULL, EFNAME VARCHAR(20), ELNAME VARCHAR(20) ); When I run these sql statements in PhpMyAdmin it does not add E# but changes the EFNAME to EEFNAME. Thanks. Just don't do this... I doubt you can justify this. Quote Link to comment https://forums.phpfreaks.com/topic/73103-how-can-i-create-a-fieldname-having-symbols-in-it-like/#findComment-369855 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.