Deleting everything EXCEPT ...

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
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Deleting everything EXCEPT ...

Post by phice »

What's the query line to DELETE * FROM table WHERE id DOES NOT EQUAL 164


something like that...
Image Image
fatalcure
Forum Contributor
Posts: 141
Joined: Thu Jul 04, 2002 12:57 pm
Contact:

Post by fatalcure »

Code: Select all

$query="DELETE FROM table WHERE id <> 164";
mysql_query($query);
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post by phice »

even if you have charectors inside the EXCEPT value?

like... would "DELETE FROM table WHERE name <> their_name184" work?
Image Image
fatalcure
Forum Contributor
Posts: 141
Joined: Thu Jul 04, 2002 12:57 pm
Contact:

Post by fatalcure »

yea, it should:

DELETE FROM table WHERE name <> 'user_name'
Post Reply