1

我有一个数据库员工

EMPLOYEE_ID FIRST_NAME LAST_NAME SALARY DEPARTMENT JOINING_DATE

      1       John      Abraham     1000000      Banking     2013-01-01
      2       Michael   Clarke      800000       Insurance   2013-01-01 
      3       Roy       Thomas      700000       Banking     2013-02-01 

我的查询是:Get position of 'o' in name 'John' from employee table!在 postgresql 中!

我试过 ::SELECT position('o' IN 'John');但我想把约翰从桌子上拿下来!有没有办法这样做?

4

1 回答 1

0

这个怎么样?

SELECT position('o' IN FIRST_NAME) FROM employee WHERE FIRST_NAME = 'John';

如果你想要全名的职位,你可以这样做:

SELECT position('o' IN FIRST_NAME || ' ' || LAST NAME) FROM employee WHERE FIRST_NAME = 'John';
于 2013-07-05T05:41:56.903 回答