开发者

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.)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜