3665 posts Ruben Bristian
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 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..

23 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Sells items exclusively on Envato Market
  • Won a Most Wanted contest
+5 more
audemedia says

AND p.post_excerpt NOT LIKE ‘ link ‘

23 posts
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Sells items exclusively on Envato Market
  • Won a Most Wanted contest
+5 more
audemedia says

inside the quotes : link

forum removes this symbol % :-(

1468 posts The Last Man Standing
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Sells items exclusively on Envato Market
+8 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
301 posts
  • Has been part of the Envato Community for over 2 years
  • Sells items exclusively on Envato Market
crossroad says

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

1468 posts The Last Man Standing
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Sells items exclusively on Envato Market
+8 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

1468 posts The Last Man Standing
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Sells items exclusively on Envato Market
+8 more
ImanGM says

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

301 posts
  • Has been part of the Envato Community for over 2 years
  • Sells items exclusively on Envato Market
crossroad says

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

1468 posts The Last Man Standing
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $75,000+ on Envato Market and is now an Elite Author
  • Has been a beta tester for an Envato feature
  • Sells items exclusively on Envato Market
+8 more
ImanGM says

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

My pleasure :sunglasses:

3665 posts Ruben Bristian
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has sold $500,000+ on Envato Market
  • Has been part of the Envato Community for over 6 years
+10 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?

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by