3507 posts Ruben Bristian
  • Most Wanted Bounty Winner
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 6-7 years
  • Repeatedly helped protect Envato Market against copyright violations
  • Won a Competition
  • Bought between 100 and 499 items
  • Exclusive Author
  • Referred between 500 and 999 users
+5 more
KrownThemes says

Hello all

I have this SELECT query and i’m trying to select all posts except the ones which have a certain excerpt. Is it possible?

SELECT p.ID FROM wp_posts AS p WHERE p.post_date > '2013-09-23 09:37:37' AND p.post_type = 'portfolio' AND p.post_excerpt != 'link' AND p.post_status = 'publish' ORDER BY p.post_date ASC LIMIT 1

So i basically want to select a post which has any excerpt than “link”. Obviously it doesn’t work.. It works with the equal sign, but i don’t know how to test against something..

16 posts
  • Bought between 1 and 9 items
  • Sold between 50 000 and 100 000 dollars
  • Most Wanted Bounty Winner
  • Exclusive Author
  • Europe
  • Envato Studio (Microlancer) Beta Tester
  • Football Contest Participant/Runner-up
  • Has been a member for 2-3 years
audemedia says

AND p.post_excerpt NOT LIKE ‘ link ‘

16 posts
  • Bought between 1 and 9 items
  • Sold between 50 000 and 100 000 dollars
  • Most Wanted Bounty Winner
  • Exclusive Author
  • Europe
  • Envato Studio (Microlancer) Beta Tester
  • Football Contest Participant/Runner-up
  • Has been a member for 2-3 years
audemedia says

inside the quotes : link

forum removes this symbol % :-(

1202 posts The Last Man Standing
  • Community Superstar
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Author had a Free File of the Month
  • Has been a member for 3-4 years
  • Referred between 10 and 49 users
  • Exclusive Author
  • Bought between 10 and 49 items
+2 more
ImanGM says

Hey!

You should try this:

SELECT p.ID FROM wp_posts AS p WHERE p.post_date > '2013-09-23 09:37:37' AND p.post_type = 'portfolio' AND p.post_excerpt NOT like '%link%' AND p.post_status = 'publish' ORDER BY p.post_date ASC LIMIT 1
293 posts
  • Exclusive Author
  • Has been a member for 2-3 years
crossroad says

What version of MySQL are you using? 5.1+ should suppport != if it does not, try this <>

1202 posts The Last Man Standing
  • Community Superstar
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Author had a Free File of the Month
  • Has been a member for 3-4 years
  • Referred between 10 and 49 users
  • Exclusive Author
  • Bought between 10 and 49 items
+2 more
ImanGM says

Just forgot to say. I guess NOT LIKE is better for looking in excerpt which is a MEMO type but if you want to use against operator, you should use <> not !=

Cheers,
Iman

1202 posts The Last Man Standing
  • Community Superstar
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Author had a Free File of the Month
  • Has been a member for 3-4 years
  • Referred between 10 and 49 users
  • Exclusive Author
  • Bought between 10 and 49 items
+2 more
ImanGM says

Haha! @audemedia and @crossroad said what is needed before me. My posts where both useless :D

293 posts
  • Exclusive Author
  • Has been a member for 2-3 years
crossroad says

@imangm: All of your posts are very useful, as you are one of most helpful person around.

1202 posts The Last Man Standing
  • Community Superstar
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Author had a Free File of the Month
  • Has been a member for 3-4 years
  • Referred between 10 and 49 users
  • Exclusive Author
  • Bought between 10 and 49 items
+2 more
ImanGM says

@imangm: All of your posts are very useful, as you are one of most helpful person around.

My pleasure :sunglasses:

3507 posts Ruben Bristian
  • Most Wanted Bounty Winner
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 6-7 years
  • Repeatedly helped protect Envato Market against copyright violations
  • Won a Competition
  • Bought between 100 and 499 items
  • Exclusive Author
  • Referred between 500 and 999 users
+5 more
KrownThemes says

Hey guys, thanks a lot for your help, i’ve gone with NOT like and it works. However, i had to remove the percentages, otherwise it didn’t work.

My query is like this:

... AND p.post_excerpt NOT like 'link' AND ...

Does it matter that i don’t have the ”%” sign? Will it affect other users?

by
by
by
by
by
by