MySQL
The full form of MYSQL is My Structured Query Language. It is a popular open-source relational database
management system (RDBMS) that is used for storing and managing data.
It allows users to create, modify, and query a database, as well as manage the security and access controls for that
database.
Queries :
To create database : create database database_name ;
To see all databse present in server : show databases;
To use a specific database : use database_name;
To create table and its structure into database : create table table_name(column_name datatype , column_name
datatype (size));
To set column key and more properties : Create table table_name ( Column_name datatype not null
auto_increment primary key );
To Changing properties of existing column : alter table table_name modify column column_name datatype not null
auto_increment primary key ;
**It will be alter column only if column fulfil all confition according to its oroperties . i.e if column have any of null record or duplicate data it will
shows u error .
To insert data into table : insert into students value ( data 1 , data 2 )
To see table structure : desc table_name ;
To see table datas: select * from table_name;
To see specific column of table : select column_name from table_name ;
To see specific column if condition if fulfill : select * from table_name where condition;
To see multiple colmn while condition fulfill : select column1, column2, ... from table_name where condition;
To see multiple column while all given conditions fulfil : select column1, column2, ... from table_name where
condition1 and condition2 and condition3 ...;
To see multiple column while any of given conditions fulfil : select column1, column2, ... from table_name where
condition1 or condition2 or condition3 ...;
To see multiple column while conditions not fulfil : Select column1, column2, ... from table_name where not
condition;
To see multiple column in ascending / decending order : select column1, column2, ... from table_name order by
column1, column2, ... asc|desc ;
To update column datas : update table_name set column1 = value1, column2 = value2, ... where condition;
To add new column : alter table table_name add column_name datatype;
To delete column : alter table table_name drop column_name datatype;
To rename column name : alter table table_name rename column old_name to new_name;
To change column properties : alter table table_name modify column column_name datatype;
To delete database : drop database databasename;
To delete table : drop table table_name;
To delete table structure only : truncate table table_name;
To delete row of table while condition fulfil : delete from table_name where condition;
To delete table data : delete from table_name;
To see min data of a column : select min(column_name) from table_name where condition;
To see no.of data in a column : select count(column_name) from table_name where condition;
To see sum of data of a column : select sum(column_name) from table_name where condition;
To see avg of data of a column :select avg(column_name) from table_name where condition;
To join to tables and see in a single default table :
select column1, columnA, column2 from table_name1 inner join table_name2 on
table_name1.column_name = table_name2.column_name ;
select column1, columnA, column2 from table_name1 left join table_name2 on table_name1.column_name
= table_name2.column_name ;
select column1, columnA, column2 from table_name1 right join table_name2 on
table_name1.column_name = table_name2.column_name ;
To search data by characters or numbers or symbols : select column1, column2, ... from table_name where columnN
like 'a%';
In above ‘ a%’ , % is known as wildcarts .
Wildcarts :
* Represents zero or more characters
? Represents a single character
[] Represents any single character within the brackets
! Represents any character not in the brackets
- Represents any single character within the specified range
# Represents any single numeric character