Monday, 11 December 2017

How To Search Your Name From LastName In SQL?

// Create Database

Create Database LP;   
   
 //Select Database

Use LP;          
               
//Create table DPK

Create table DPK (Employee_ID INT Not NULL,Employee_Name Varchar (20)NOT NULL, Salary INT NOT NULL,Dt_time Date NOT NULL,PRIMARY KEY (Employee_ID));   

//Retrieve  Data from DPK

Select * from DPK;

//Insert Data into
DPK

INSERT into DPK(Employee_ID, Employee_Name,Salary, Dt_time) values (237998, 'Ram Kumar',89555,'2017-8-21' );
INSERT into DPK (Employee_ID, Employee_Name,Salary, Dt_time) values (637908, 'Sham Dev',90000, '2017-8-21' );
INSERT into DPK(Employee_ID, Employee_Name,Salary, Dt_time) values (231798, 'Rohan Kumar',89555, '2017-8-22' );
INSERT into DPK (Employee_ID, Employee_Name,Salary, Dt_time) values (352908, 'Sham Parida',90000, '2017-8-23' );
INSERT into DPK (Employee_ID, Employee_Name,Salary, Dt_time) values (685098, 'Rohan Kulkarni',23555, '2017-9-21' );
INSERT into DPK (Employee_ID, Employee_Name,Salary, Dt_time) values (658990, 'Mahesh Sawant',89555, '2017-9-22');
INSERT into DPK (Employee_ID, Employee_Name,Salary, Dt_time) values (658990, 'Rakesh Kulkarni',89555, '2017-9-22');
INSERT into DPK (Employee_ID, Employee_Name,Salary, Dt_time) values (658990, 'Kalyani Sawant',89555, '2017-9-22');

//Retrieve  Data from DPK

Select * from DPK;

Search Your Name From Lastname

Syntax:-
SELECT FIELD NAME FROM TABLE NAME where FIELD NAME LIKE '%LAST NAME%';

Example:
Select Employee_Name from  DPK  Where Employee_Name  like '%kulkarni%';

Output:
Rohan Kulkarni

Rakesh Kulkarni

No comments:

Post a Comment

apply function in R

1) apply function: It takes 3 arguments matrix,margin and function.. Example: m<-matrix(c(1,2,3,4),nrow=2,ncol=2) m #1 indicates it is ap...