Solved

Help with Search Query - Using And/or

Posted on 2011-03-19
3
261 Views
Last Modified: 2012-05-11
I am having a hard time getting the right results, its still including the word minifig in the return and I am trying to filter that out:

select distinct  item_title, sold_price
from products
where product_type = 1
AND (item_title like '%2114%')
AND (item_title not like '%mini%figure%' or item_title not like '%minifig%')
AND (item_title LIKE '%chopov%')       
ORDER BY sold_price desc

This is the result I am getting back.  The word minifig is clearly still in there.  How can i do this query to work better?
----------------------------------------------------------

new lego ninjago chopov spinner 2114
lego ninjago  ''chopov''   2114   nib        new
lego 2114 ninjago chopov battle pack new
lego ninjago skeleton warrior chopov minifig 2259 2114
lego ninjago-chopov 2114 w/ black spinner brand new
new lego 2114 figure chopov in hand ninjago rare 2011
new lego ninjago chopov (2114)
lego ninjago skeleton warrior chopov minifig 2259 2114
lego ninjago skeleton warrior chopov minifig 2259 2114
lego ninjago skeleton warrior chopov minifig 2259 2114
lego ninjago skeleton warrior chopov minifig 2259 2114
lego ninjago skeleton warrior chopov minifig 2259 2114
lego ninjago skeleton warrior chopov minifig 2259 2114
lego ninjago skeleton warrior chopov minifig 2259 2114
lego ninjago-chopov 2114 w/ black spinner brand new
lego ninjago skeleton warrior chopov minifig 2259 2114
lego ninjago skeleton warrior chopov minifig 2259 2114
lego ninjago chopov 2114
0
Comment
Question by:theideabulb
  • 2
3 Comments
 
LVL 2

Accepted Solution

by:
michael_madsen earned 500 total points
ID: 35172542
select distinct  item_title, sold_price
from products
where product_type = 1
AND (item_title like '%2114%')
AND (item_title not like '%mini%figure%')
AND (item_title not like '%minifig%')
AND (item_title LIKE '%chopov%')      
ORDER BY sold_price desc
0
 

Author Comment

by:theideabulb
ID: 35172548
Yes that worked much better, why does it need the AND and not work with the OR in the parenthesis?
0
 
LVL 2

Expert Comment

by:michael_madsen
ID: 35172579
Basically what you have in that line is two conditions:

1) Item-title should not contain 'mini%figure'
2) Item-title should not contain 'minifig'

with "or" you are saying that either one can evaluate to true for the whole line to evaluate to true.

So Item-title like: "Lego ninjago skeleton warrior chopov minifig 2259 2114" evaluates like:

1) true
2) false

problem is that with "or" your whole line is still true.
0

Featured Post

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction In this article, I will by showing a nice little trick for MySQL similar to that of my previous EE Article for SQLite (http://www.sqlite.org/), A SQLite Tidbit: Quick Numbers Table Generation (http://www.experts-exchange.com/A_3570.htm…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question