0% found this document useful (0 votes)
4 views

sql_queries

sql database quaries in feturea

Uploaded by

amithukum777
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

sql_queries

sql database quaries in feturea

Uploaded by

amithukum777
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

how many databases?

->show databases;
--------------------------------------------------------------------------
clear system
system cls;
--------------------------------------------------------------------------
use database
use databasename;
-----------------------------------------------------------------------------
to know list of table
show tables;
-----------------------------------------------------------------------------
select database
select databasename();
-------------------------------------------------------------------------------
create table

crate table tablename(col_name1 type(size),col_name2 type(size)......);


-------------------------------------------------------------------------------
insert data in a table-
insert into tablename(col_name1, colname2......)values(value1 ,value2......);
--------------------------------------------------------------------------------
structure of table
desc tablename;
----------------------------------------------------------------------------------
where clause-it is a condition
select col/(*) from tablename where cond;
--------------------------------------------------------------------------------
delete syntax- delete from table name where condition;
eg: delete from employee where empno=116;

delete all values:


eg: delete from employee;
-----------------------------------------------------------------------------------
---------
update statement:- it is used to update the data of the table.
synatx-

update tablename set column_name=value,columne_name= value,.....where condition;


eg: update student set city='ujjain' where rollno=115;

update all records:

update tablename set cond = cond;


update student set fees = fees+1000;
-----------------------------------------------------------------------------------
---------------
Operators-

and & or operator:--when we use "and" operator both cond should be true whereas in
"or" operator either one or both condition should be true.
syntax-- sql statement where cond1 and cond 2;

eg:
select * from student where city='bhopal' and class = 'bcom';
note: "and" operator return when both cond's are true.
---------------------------
syntax-- sql statement where cond1 or cond 2;

eg:
select * from student where city='bhopal' or class = 'bcom';

note: either both cond or one cond.


----------------------------------------------------------------------
between - it always work with numeric types of value. use to find record between
two range.

syntax:--
sql statement where columname between lower_limit and upper_limit.

eg:
select * from student where fees between 20000 and 40000;
-----------------------------------------------------------------------------------
--------
in and not in operator:--

select * from student where city in('bhopal','indore','jabalpur');


-----------------------------------------------------------------------------------
---------
order by:- use to sort records either in asce or desc order
for descending we can use "desc" keywords

eg:

select * from student order by rollno;

select * from student order by name,city;

select * from student order by rollno desc;

select * from student order by name,city desc;

-----------------------------------------------------------------------------------
-------------

You might also like