Learn Python

Learn Data Structure & Algorithm

Learn Numpy

Learn Pandas

Learn Matplotlib

Learn Seaborn

Learn Statistics

Learn Math

Learn MATLAB

Learn Machine learning

Learn Github

Learn OpenCV

Learn Deep Learning

MySQL Introduction

MySQL Setup

MySQL Operators

MySQL Basic Works

MySQL Create Table

MySQL insert and get values

MySQL Condition

MySQL GROUP BY

MySQL Case

MySQL sorting and calculate avg,sum,count

MySQL Update

MySQL Time

MySQL String

MySQL Rollback & Commit

MySQL Join and Concatenate

MySQL Index

MySQL Date

MySQL View

MYSQL With Python

Learn MongoDB

Learn Web scraping

Learn Excel

Learn Power BI

Learn Tableau

Learn Docker

Learn Hadoop

Everything about insert value and get value of a table in sql

How to put values in a table?

Syntax:
inset into table_name(all columns name ) values (value,value),(value,value)...;

Example:
create database books_store;
use books_store;
create table books_store_1(books varchar(100) NOT NULL,price int NOT NULL);

/*Let's put some values*/
insert into books_store_1(books,price) values("SQL",430),("Python",323),("Javascript",300),("Data science",1000);

Here we have created a database named books_store. Then we use it and then we created a table named books_store_1 and in the table, we have two columns one is book and the other is price. After that we put values in the table.

How to get a selected database table values?

Syntax:
Select * from table_name;

Example:
select * from books_store;

How to get a selected column values of a table from a database?

Syntax:
select columns_name( give comma between column names) from table_name;

Example:
select books,price from books_store_1;

How to update value of a table?

Syntax:
update table_name set column_name=value where condition;

Example:
update books_store_1 set price=400 where books="Python";
What we did here, we set the price 400 of the python book.

How to get value of a column according to given creators?

If you use percent(%) sign before your specified letters( which you want to find), it means you want strings which contain your specified letters at the end of the word and it doesn't matter what are letters are present before your specified letters.

If you use percent(%) sign after your specified letters( which you want to find), it means you want strings which contain your specified letters at the starting of the word and it doesn't matter what are letters are present after your specified letters.

If you use percent(%) sign both sides of your specified letters( which you want to find), it means you want to get those strings which contain your specified letters and it doesn't matters what are the letters are present after and before of your specified letters.

Syntax:
select * from table_name where column_name like"letters";

Example 1:
select * from books_store_1 where book like "%th";

Example 2:
select * from books_store_1 where book like "th%";

Example 3:
select * from books_store_1 where book like "%th%";

How to get minimum and maximum value of a column?

Syntax:
SELECT MAX(column_name) AS write_any_name_for_smallest_price
FROM table_name;

Example:
SELECT MIN(Price) AS smallest_price
FROM first_table;
SELECT MAX(column_name) AS write_any_name_for_smallest_price
FROM table_name;

Example:
SELECT MIN(Price) AS maximum_price
FROM first_table;

How to get unique values of column?

To see the unique value of a column, use DISTINCT. To see multiple columns' unique value, write all the column names which maximum or minimum value you want to see and between column names give comma.

Syntax:
Select DISTINCT column_name from table_name;
Select DISTINCT column_name,column_name,column_name from table_name;

Example:
Select DISTINCT books from books_store_1;
Select DISTINCT books,price from books_store_1;

CodersAim is created for learning and training a self learner to become a professional from beginner. While using CodersAim, you agree to have read and accepted our terms of use, privacy policy, Contact Us

© Copyright All rights reserved www.CodersAim.com. Developed by CodersAim.