Friday, January 1, 2021

CAST AND CONVERT & SUBSTRING OR REPLACE OR CONCAT FUNCTION

 

Cast & convert is used to chenge the one data type to other data type.

example : 

select  cast (200 as char) 

example : 

select  convert (200 as char) 

SUBSTRING FUNCTION  

select substring(firstname,1,3) from table1

Print First name till 3 char

# Output :

    'Tar'

Removing white spaces from the Right side

# select RTRIM(firstname,1,3) from table1  

Removing white spaces from the Light side

example :

# select RTRIM(firstname,1,3) from table1 

REPLACE FUNCTION

example :

# select REPLACE(firstname,'a','A') from table1  

CONCAT 

example :

# select concat(firstname,' ',lastname) Name from table1

ORDER BY : 

example :defult  accending

# select  firstname  from table1 order by fistname

example :

# select  firstname  from table1 order by fistname  desc

IN:

select * from  table where firstname in ('tom','dk')


No comments:

Post a Comment

How to Find the Third highest salary in mysql

  set @b:=0; set @b1:=3;   # #select distinct salary,@b:=@b+1 as Row_no from emp select  * from emp where salary=( select salary from ( sele...