Viry Posted April 29, 2009 Share Posted April 29, 2009 Hi, Could someone please help me improve this query and try to cut down on the repeated "`id` != '*'" parts. SELECT `id`, `user`, `usertwo`, `time` FROM `feeds` WHERE `user` = '1' AND `id` != '38000' AND `id` != '38007' OR `usertwo` = '1' AND `id` != '38000' AND `id` != '38007' OR `usertwo` IN ( SELECT `frdid` FROM `friends` WHERE `userid` = '1' ) AND `id` != '38000' AND `id` != '38007' OR `usertwo` IN ( SELECT `fb_uid` FROM `service_friends` WHERE `userid` = '1' ) AND `id` != '38000' AND `id` != '38007' ORDER BY `time` DESC LIMIT 1 Link to comment https://forums.phpfreaks.com/topic/156111-mysql-query-improvement/ Share on other sites More sharing options...
fenway Posted April 29, 2009 Share Posted April 29, 2009 You're mixing ANDs and ORs... that's not going to work. Link to comment https://forums.phpfreaks.com/topic/156111-mysql-query-improvement/#findComment-821808 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.