Modify the query select John Smith from DUAL This time use t
Modify the query select \'John Smith\' from DUAL;. This time, use the SUBSTR function to extract a substring that represents your last name from the text string \'your_first_name your_last_name\'. Assume you know the number of characters you need to extract.
Modify the query select \'John Smith\' from DUAL; . This time, use the INSTR and SUBSTR functions to extract a substring that represents your first name from the text string \'your_first_name your_last_name\'. Assume you do not know the number of characters to extract.
Modify the query select \'John Smith\' from DUAL; . This time, use the INSTR, SUBSTR, and LENGTH functions to extract a substring that represents your last name from the text string \'your_first_name your_last_name\'. Assume you do not know the number of characters you need to extract.
Solution
1. SUBSTR function to extract the last name
select SUBSTR(\'John Smith\', 6,10) from DUAL;
2. INSTR and SUBSTR functions to extact the first name
select SUBSTR(\'John Smith\', 1,INSTR(\'John Smith\', \' \',1,1)) from DUAL;
3.INSTR ,SUBSTR and LENGTH functions to extact the first name
select SUBSTR(\'John Smith\',INSTR(\'John Smith\', \' \',1,1),LENGTH(\'John Smith\')) from DUAL;
