开发者

SQl Trim problem

I am trying to pull data from table using this select statem开发者_StackOverflow社区ent..

SELECT ID_NO
FROM EMPLOYEE
WHERE trim(SYN_NO) ='21IT';

SYN_NO column hold data in this format

21IT / 00065421

I want to get just first four characters and drop rest of it.. i tried trim, rtrim but it didnt work. Is there a way to do this.. Thank you


Sadly for those of us coming from SQL Server, there is no LEFT in oracle. The article I linked below talks about one person's encounter with this problem, and recommends using

SUBSTR(SYN_NO,1,4)

(see article)

Oracle SUBSTR specification


Sorry, just realized this is Oracle. You need to use SUBSTR:

SELECT ID_NO
FROM EMPLOYEE
WHERE SUBSTR(SYN_NO, 1, 4) ='21IT';


In Oracle, you'd use the SUBSTR function

SELECT id_no
  FROM employee
 WHERE substr(syn_no,1,4) = '21IT'
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜