Jump to content

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?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.