Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

can I optimize this query?

From: Patrick Aljord <patcito(at)gmail.com>
Date: Mon Jun 25 2007 - 12:22:02 EDT


Hey all,
I have 2 tables:
Profiles(id).
Relationships(id,friend_id,befriender_id).

friend_id and befriender_id represent profiles ids.

I want to find all the profiles that are neither friends neither befrienders with a given profile.

this is the query I use with profile id=1:

select * from profiles
  where profiles.id not in
  (SELECT profiles.id FROM profiles INNER JOIN relationships ON profiles.id = relationships.befriender_id WHERE
(relationships.friend_id = 1 ))

and profiles.id not in
(SELECT profiles.id FROM profiles INNER JOIN relationships ON
profiles.id = relationships.friend_id WHERE
(relationships.befriender_id = 1 ));

is there a better, faster way to do so?

thanx in advance

Pat

-- 
MySQL General Mailing List
For list archives: 
http://lists.mysql.com/mysql
To unsubscribe:    
http://lists.mysql.com/mysql?unsub=lists@pantek.com
Received on Mon Jun 25 12:31:13 2007
Do you need help?X

This archive was generated by hypermail 2.1.8 : Mon Jun 25 2007 - 12:40:03 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library