SUBSTR() function in IF statement +----+---------------+-------+
| id | link          | title |
+----+---------------+-------+
| 1  | v_156399569   | abc   |
+----+---------------+-------+
| 2  | y_u0inSsAoFU4 | xyz   |
+----+---------------+-------+


Query:  

SELECT if(substr(link, 1, 2)='y_', 
                'https://www.youtube.com/watch?v='substr(link,3), 
                'https://vimeo.com/'substr(link,3)) as link, `title`
FROM `video`
WHERE `reg_id` = '101'  


Desired Output:  

+-------------------------------------------+-------+
| link                                      | title |
+-------------------------------------------+-------+
| https://www.youtube.com/watch?v=156399569 | abc   |
+-------------------------------------------+-------+
| https://vimeo.com/u0inSsAoFU4             | xyz   |
+-------------------------------------------+-------+


In the above query I can't use substr(link,3) function when expression is true. After v= I wanna get a sub string value of link column in the table.  

The above query fire some error. So please help me to solve this issue. Answers will be appreciated.
You can use CONCAT function to add this two strings on this way:




create table video(link varchar(200), title varchar(200));






insert into video values ('y_LjhCEhWiKXk', 'Bruno Mars - Just The Way You Are [OFFICIAL VIDEO]');






select title,
       if(substr(link, 1, 2)='y_', 
          concat('https://www.youtube.com/watch?v=', substr(link,3)), 
          concat('https://vimeo.com/', substr(link,3))) as link
from   video;



title                                              | link                                       
:------------------------------------------------- | :------------------------------------------
Bruno Mars - Just The Way You Are [OFFICIAL VIDEO] | https://www.youtube.com/watch?v=LjhCEhWiKXk



dbfiddle here