Jump to content

Help grouping a query


kn0wl3dg3

Recommended Posts

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  :P

 

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  :D

Link to comment
https://forums.phpfreaks.com/topic/239480-help-grouping-a-query/
Share on other sites

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?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.