mySQL not behaving as expected
I am running the following query
SELECT *
FROM wp_posts
WHERE (post_title LIKE 'Professionally')
OR (post_content LIKE 'Professionally')
AND post_type='post'
AND post_status='publish'
I know that I have a row that has post_type
of post
, and post_status
of publish
that starts with the word 'Professionally' (copied and pasted from phpmyadmin) but this query returns no results.
Oddly, when the query successfully matches a popst_title开发者_StackOverflow
it works as expected.
When using LIKE, you use a %
in order to do substring matches:
SELECT *
FROM wp_posts
WHERE (post_title LIKE 'Professionally%'
OR post_content LIKE 'Professionally%')
AND post_type = 'post'
AND post_status = 'publish'
(I also modified your bracketing to better express what I think you are trying to do.)
精彩评论