kn0wl3dg3 Posted June 15, 2011 Share Posted June 15, 2011 Need help with a query I've got this code SELECT Name, Time, Description FROM Table WHERE ID = ANY (SELECT ID FROM LinkList WHERE Link LIKE '%term%') OR Name LIKE '%term%' OR Technique LIKE '%term%' OR Origin LIKE '%term%' OR Time LIKE '%term%' AND User_ID='1' OR Public=1 But its not returning the right results well it is but not the results i want I want to get the records that match the term ONLY when the last two are met. Is there a way to group this with () or something? I've tried group by but its not getting what I think should be the right results. So it should get any ids that have the term in them but only if it matches the userid OR if public is 1. Please help Link to comment https://forums.phpfreaks.com/topic/239480-help-grouping-a-query/ Share on other sites More sharing options...
Muddy_Funster Posted June 16, 2011 Share Posted June 16, 2011 SELECT Name, Time, Description FROM Table WHERE ((ID = ANY (SELECT ID FROM LinkList WHERE Link LIKE '%term%') OR Name LIKE '%term%' OR Technique LIKE '%term%' OR Origin LIKE '%term%' OR Time LIKE '%term%' ) AND (User_ID='1' OR Public=1)) is that what your looking for? Link to comment https://forums.phpfreaks.com/topic/239480-help-grouping-a-query/#findComment-1230406 Share on other sites More sharing options...
kn0wl3dg3 Posted June 16, 2011 Author Share Posted June 16, 2011 I hope so!! Ill try it asap Link to comment https://forums.phpfreaks.com/topic/239480-help-grouping-a-query/#findComment-1230453 Share on other sites More sharing options...
kn0wl3dg3 Posted June 16, 2011 Author Share Posted June 16, 2011 I do believe it is! Thank you I tried it on the exact query that I noticed the error and it brought the correct results. I'll test more but mark it solved cause I think it is Link to comment https://forums.phpfreaks.com/topic/239480-help-grouping-a-query/#findComment-1230465 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.