Something like:
SELECT IF( [call_history.callerid contains '*'], [if it contains, keep last four char], [if not, return ' '(not null)] ) AS 'test'
FROM call_history
ORDER BY start DESC;
答案 0 :(得分:0)
I recommend reading the manual page on string functions built into MySQL's flavor of SQL: http://dev.mysql.com/doc/refman/5.7/en/string-functions.html
For example:
SELECT IF(LOCATE(callerid, '*'), SUBSTRING(callerid, -4), '') AS 'test'
FROM call_history
ORDER BY start DESC;