E.g:- BRAKE,CRANE etc.
In my employees table , I have ENAME,ENO,JOB,SALARY
.
Here, I want to extract out those enames that have an ‘A’ as the center character in their name.
If length of ename is odd,then center one, so i need to detect odd and even position in ename.
So, I tried this, but stuck up ,so can i expect a help from here?
SELECT ENAME FROM EMPLOYEES WHERE A IN (SELECT ENAME, SUBSTR(ENAME,LENGTH(ENAME)/2+1,1) FROM EMPLOYEES) ;
Advertisement
Answer
This works for odd length strings, which I think is what you wanted. Next time please don’t use caps like that. It took me 5 minutes just to read your post.
SELECT `ENAME` FROM `EMPLOYEES` WHERE SUBSTR(`ENAME`, LENGTH(`ENAME`)/2+1, 1) = 'A'