SQL查询-大小写和下标

时间:2018-06-25 16:55:23

标签: sql case substr

我有一列是使用substr函数获得的,并且此列具有字母。如何将字母更改为单词?

select orderid,
       substr(ordernumber,10,1) as Process
from Table1,
where XXXXXX

如果“过程”列中有“ M”,则应将其替换为“维护”,如果是“ O”,则应为“操作”。

Process ---> Process
M            maintenance
O            Operations

有人可以帮助我如何更改substr语句以更新列吗?

2 个答案:

答案 0 :(得分:0)

您可以使用public class MainActivity extends AppCompatActivity { Context context; LinearLayout menuClcick,gallerClcik,eventsClick; LayoutInflater inflater;`enter code here` @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //we don't need to set view, our fragment will handle it setPointer(); //Fragment Manger FragmentManager fm = getFragmentManager(); //create instance of Fragment Transaction to handle fragment replace and animation FragmentTransaction ft=fm.beginTransaction(); int displayMode = getResources().getConfiguration().orientation; Log.e("WTF", "onCreate: "+displayMode ); //choose which fragment to display according to screen orientation if (displayMode==1) //portrait { // that's the Fragment that I use to display a layout in the portrait and other layout in the landscape// //create instance of our portrait fragment Fragment1 f1=new Fragment1(); //change content of the screen to our new fragment ft.replace(android.R.id.content,f1); } else { Fragment2 f2=new Fragment2(); ft.replace(android.R.id.content,f2); } //choose animation ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); //commit our changes ft.commit(); } private void setPointer() { this.context=this; menuClcick=findViewById(R.id.menuClick); gallerClcik=findViewById(R.id.gallerClcik); eventsClick=findViewById(R.id.eventsClick); //this is the problem the app have no problem to find the buttons but it stops working when I try to put onclick listener in it// menuClcick.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Toast.makeText(context, "portrait", Toast.LENGTH_SHORT).show(); } }); } 表达式:

case

答案 1 :(得分:0)

使用带有case表达式的更新语句:

update table 
     set Process = (case substr(ordernumber, 10, 1) 
                         when 'M' then 'maintenance'
                         when 'O' then 'Operations'
                    end)
where substr(ordernumber, 10, 1) in ('M', 'O');