Reputation: 2651
I am currently searching my database with the following query. What I really need to do is get 30 results that do not include the tag #DONE#
that is contained in the information column. The structure of the database is below:
ID Info1 Info2 Info3 DateAdded
-----------------------------------------------------------------
1235 0000 6 #DONE#infohere 35:27.9
5678 1111 5 #DONE#infohere 47:15.4
4583 2222 7 otherinfohere 47:36.8
1238 3333 9 otherinfohere 47:12.6
Current Query:
SELECT * FROM $tablename WHERE `Info3` <> '' LIMIT 0,30
So in the full database there is more than 30 of both Info3
columns that have the #DONE#
tag and do not have the #DONE#
tag. What I need to be able to do it to exclude all the results that have the #DONE#
tag. I do not want to just get all results as that would be extensive on the database when it gets larger but I do need 30 results in the end. Any suggestions?
Upvotes: 0
Views: 32
Reputation: 5488
Try this -
SELECT * FROM $tablename WHERE `Info3` not like '#DONE#%' LIMIT 0,30
Upvotes: 1
Reputation: 15848
you want NOT LIKE
SELECT * FROM $tablename WHERE `Info3` NOT LIKE '#DONE#%' LIMIT 0,30
EDIT: if #DONE# is not always at the beginning, use %#DONE#%
SELECT * FROM $tablename WHERE `Info3` NOT LIKE '%#DONE#%' LIMIT 0,30
Upvotes: 3