Reputation: 8156
I'd like to use LIKE or REGEX in the SELECT statement of the query (not in the WHERE statement).
If the post_content contains 'base64' I'd like to see 1 in the query output. Is it possible?
SELECT post_content, length(post_content), LIKE('%base64%') AS contained
FROM `wp_posts`
order by length(post_content) desc
Upvotes: 0
Views: 89
Reputation: 1153
You can use the Case statement
SELECT post_content, length(post_content),
(CASE WHEN post_content LIKE('%base64%') then "contained " ELSE "not contained" END) AS contained
FROM `wp_posts`
order by length(post_content) desc
OR
SELECT post_content, length(post_content),
post_content LIKE('%base64%') AS contained
FROM `wp_posts`
order by length(post_content) desc
Upvotes: 3