Re: SQL Queries

From: Date: Mon, 21 Dec 2009 13:46:05 +0000
Subject: Re: SQL Queries
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-300623@lists.php.net to get a copy of this message
You should be able to do this from within the query. Try the following query: DELETE users.* FROM users LEFT JOIN notes USING(user_id) WHERE notes.note_id IS NULL Take care, Floyd On Dec 20, 2009, at 4:30 PM, דניאל דנון wrote: > Hey, Lets assume I got a table named "users". > It contains id & name. > > I have another table called "notes" - which contains id, user_id, contents > > > I want to delete all users from table "users" that don't have notes (SELECT > ... FROM notes WHERE user_id=ID) returns empty result. > > > What is the fastest way to do it? > > -- > Use ROT26 for best security

« previous php.general (#300623) next »