AV1611 Posted December 26, 2006 Share Posted December 26, 2006 I need to delete a column from a table on the fly$sql=mysql_query('');assume table name mytable and columns aaa, bbb, ccc I want to remove column bbb altogether.I could do $sql=mysql_query('create table newtable select aaa,ccc from oldtable');but that's not really what I want to do... Link to comment https://forums.phpfreaks.com/topic/31908-delete-a-column/ Share on other sites More sharing options...
Psycho Posted December 26, 2006 Share Posted December 26, 2006 Hmm. a google search for "mysql delete column" brought up several pages with solutions. All in less than 1 second:ALTER TABLE tableName DROP columnName Link to comment https://forums.phpfreaks.com/topic/31908-delete-a-column/#findComment-148073 Share on other sites More sharing options...
AV1611 Posted December 26, 2006 Author Share Posted December 26, 2006 Yea, I googled it, but for some reason that didn't work for me...[code]$sql = mysql_query("ALTER TABLE 'mbl' DROP 'ip'");[/code]can you tell me why???Is it because I used '' instead of `` for the column name? Link to comment https://forums.phpfreaks.com/topic/31908-delete-a-column/#findComment-148074 Share on other sites More sharing options...
Barand Posted December 27, 2006 Share Posted December 27, 2006 [quote author=AV1611 link=topic=119979.msg491870#msg491870 date=1167172527]Is it because I used '' instead of `` for the column name?[/quote]Very probable. One easy way to find out for yourself is to change all ' to ` and try again. Link to comment https://forums.phpfreaks.com/topic/31908-delete-a-column/#findComment-148103 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.