delete some field in database

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Vietboy
Forum Commoner
Posts: 41
Joined: Mon Dec 01, 2003 10:59 pm

delete some field in database

Post by Vietboy »

how would you delete some entries inside the mySQL database without dropping it?
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

You want to delete a column? or give a cell a certain value (i.e. "". NULL)?
User avatar
devork
Forum Contributor
Posts: 213
Joined: Fri Aug 08, 2003 6:44 am
Location: p(h) developer's network

Post by devork »

are you talking about deleting certain records in database table?
User avatar
infolock
DevNet Resident
Posts: 1708
Joined: Wed Sep 25, 2002 7:47 pm

Post by infolock »

if you want to delete an entry, you should just use DELETE query.

Refer to your manual for more indepth documentation that was included in your mysql distribution, or refer to mysql's site.

here's an example though :

Code: Select all

mysql_query("DELETE from loginfo where user = 'bob'");
if you are wanting to just drop a field from the table, use this :

Code: Select all

mysql_query("ALTER TABLE `mytable` DROP `my_column_name_to_drop'");
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

If wanted to clean out the entire table-data, but leaving the layout as is:

Code: Select all

TRUNCATE TABLE;
Post Reply