Home » MySQL

How to find the nth highest salary in SQL ?

Published on 16-Dec-2021 16:52:22
This is how we can find the nth highest salary in SQL SERVER using TOP keyword: SELECT TOP 1 salary FROM ( SELECT DISTINCT TOP N salary FROM Employee ORDER BY salary DESC ) AS temp ORDER BY salary This is how we can find the nth highest salary in MYSQL using LIMIT keyword: SELECT salary FROM Employee ORDER BY salary DESC LIMIT N-1, 1 ... Read More

How to insert multiple rows in SQL ?

Published on 16-Dec-2021 16:49:13
To insert multiple rows in SQL we can follow the below syntax: INSERT INTO table_name (column1, column2,column3...) VALUES (value1, value2, value3…..), (value1, value2, value3….), ... (value1, value2, value3); We start off by giving the keywords INSERT INTO then we give the name of the table into which we would want to insert the values. We will follow it up with the list of the columns, for which we would have to a... Read More

What is a unique key in SQL ?

Published on 16-Dec-2021 16:40:54
Unique Key is a constraint in SQL. So, before understanding what exactly is a primary key, let’s understand what exactly is a constraint in SQL. Constraints are the rules enforced on data columns on a table. These are used to limit the type of data that can go into a table. Constraints can either be column level or table level. Unique Key:  Whenever we give the constraint of unique key to a column, this would mean that the column cannot ... Read More

How to delete a column in SQL ?

Published on 16-Dec-2021 16:39:14
To delete a column in SQL we will be using DROP COLUMN method: ALTER TABLE employees DROP COLUMN age; We will start off by giving the keywords ALTER TABLE, then we will give the name of the table, following which we will give the keywords DROP COLUMN and finally give the name of the column which we would want to remove.... Read More

What is MYSQL ?

Published on 14-Dec-2021 17:11:27
To understand exactly what is MYSQL, we need to understand what is DBMS and RDBMS. DBMS stands for Database Management System. When we have a huge database with us, we would need a proper management system which would help us organise this database.  There are 4 types of database management systems: Hierarchical Network Relational Object – Oriented. Out of these database management systems, MYSQL comes under the category of... Read More

What is Primary Key in SQL ?

Published on 14-Dec-2021 17:04:38
Primary Key is a constraint in SQL. So, before understanding what exactly is a primary key, let’s understand what exactly is a constraint in SQL. Constraints are the rules enforced on data columns on a table. These are used to limit the type of data that can go into a table. Constraints can either be column level or table level. Let’s look at the different types of constraints which are present in SQL: Constraint Description ... Read More

How to insert date in SQL ?

Published on 14-Dec-2021 16:59:11
If the RDBMS is MYSQL, this is how we can insert date: INSERT INTO tablename (col_name, col_date) VALUES (‘DATE: Manual Date’, ‘2020-9-10’); ... Read More

How to Create a Table in SQL – Postgres and MySQL Example Query

Published on 27-Oct-2021 16:11:38
Knowing how to create tables in SQL is an important and fundamental concept. In this tutorial, I will walk you through the SQL syntax for the CREATE TABLE statement using code examples for both PostgreSQL and MySQL. Basic CREATE TABLE Syntax Here is the basic syntax for the CREATE TABLE statement: CREATE TABLE table_name( column1 data_type column_constraint, column2 data_type column_constraint, column3 data_type colu... Read More