Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • Software and Tools
    • School Learning
    • Practice Coding Problems
  • Go Premium
  • Databases
  • SQL
  • MySQL
  • PostgreSQL
  • PL/SQL
  • MongoDB
  • SQL Cheat Sheet
  • SQL Interview Questions
  • MySQL Interview Questions
  • PL/SQL Interview Questions
  • Learn SQL and Database
Open In App
Next Article:
What is SQL?
Next article icon

SQL Tutorial

Last Updated : 25 Jun, 2025
Comments
Improve
Suggest changes
Like Article
Like
Report

Structured Query Language (SQL) is the standard language used to interact with relational databases. Whether you want to create, delete, update or read data, SQL provides the structure and commands to perform these operations. SQL is widely supported across various database systems like MySQL, Oracle, PostgreSQL, SQL Server and many others.

This tutorial covers everything from fundamental SQL concepts to advanced features, helping beginners and professionals master SQL for real-world applications.

Writing First SQL Program

Before running SQL queries you need to set up a database server like MySQL, PostgreSQL or SQLite. Here, we are going to use MySQL server. Follow below steps to set up a basic SQL Environment:

  1. Install MySQL in your system
  2. Start MySQL Server
  3. Access MySQL Command Line

After your MySQL environment is set up, you can write your SQL program. Below is the example to display " Hello World" using SQL.

1. Create a database named test_db

CREATE DATABASE test_db;

2. Use the test_db database

USE test_db;

3. Create a table named greetings

CREATE TABLE greetings (
id INT AUTO_INCREMENT PRIMARY KEY,
message VARCHAR(255)
);

3. Insert the message 'Hello, World!' into the greetings table

INSERT INTO greetings (message)
VALUES ('Hello, World!');

4. Retrieve the message from the greetings table

SELECT message FROM greetings;
Hello-World

Note: Try replacing "Hello World!" with your name in the SQL query. It's a fun way to see how databases store and display your own data! Give it a try and watch your name pop up!

Why Learn SQL?

SQL's integration with various technologies makes it essential for managing and querying data in databases. Whether it is in traditional relational databases (RDBMS) or modern technologies such as machine learning, AI and blockchain, SQL plays a key role. It works effortlessly with DBMS to help users interact with data, whether stored in structured RDBMS or other types of databases.

  • Data Science & Analytics: Used for querying large datasets, data cleaning and analysis. Analysts use SQL to generate reports and insights that inform business decisions.
  • Machine Learning & AI: Helps in preparing and managing the data required for training machine learning models and AI algorithms. It is used for data cleaning, transformation, and extraction.
  • Web Development: Used to manage user data, e-commerce transactions, and content management in websites and applications built with frameworks like Django, Node.js, and Ruby on Rails.
  • Cloud and Big Data: SQL is integrated into cloud-based databases (e.g., Amazon RDS, Microsoft Azure SQL) and Big Data platforms (e.g., Apache Hive) to enable seamless data querying and management.
  • Blockchain and Decentralized Systems: In blockchain systems, SQL can be used to manage off-chain data, providing efficient data storage and retrieval alongside decentralized ledger technology

How SQL work?

how_sql_works

When you interact with a database, you commonly use SQL commands to request operations like retrieving or modifying data. These commands are processed by the SQL Engine, which breaks down, optimizes and executes them efficiently. The SQL Engine ensures the database operates smoothly, handling all data retrieval and updates.

While DBMS tools like MySQL and SQL Server provide interfaces to write SQL queries. These tools provide a user-friendly way to write and execute SQL queries, but internally they rely on their respective SQL Engines to process these commands.

For example, MySQL uses its own SQL Engine to parse, optimize and execute queries, while SQL Server has a different SQL Engine for the same task. These engines ensure that SQL queries are executed in a way that respects the underlying database structure and the specific DBMS optimizations.

SQL Basics

Learn the foundational concepts of SQL, essential for anyone working with relational databases. This section covers the syntax, commands, and key elements to start querying and managing data effectively.

  • Introduction
  • Data Types
  • Operators
  • Commands

SQL Database

This section guides you through the process of creating and managing databases. Learn how to create, select, rename, and drop databases with practical examples.

  • CREATE Database
  • DROP Database
  • RENAME Database
  • SELECT Database

SQL Tables

Tables are the core data structures in databases, organizing data into rows and columns. This section covers how to create, modify, and manage tables effectively.

  • CREATE TABLE
  • DROP TABLE
  • RENAME TABLE
  • TRUNCATE TABLE
  • COPY TABLE
  • TEMP TABLE
  • ALTER TABLE

SQL Queries

Master writing SQL queries to interact with and manipulate data stored in your tables. This section covers common query types and operations.

  • SELECT Statement
  • INSERT INTO
  • INSERT Multiple Rows
  • UPDATE Statement
  • DELETE Statement
  • DELETE Duplicate Rows

SQL Clauses

Unlock powerful ways to filter, organize, and group your query results. Clauses help you refine your data extraction.

  • WHERE Clause
  • WITH Clause
  • HAVING Clause
  • ORDER By Clause
  • Group By Clause
  • LIMIT Clause
  • Distinct Clause
  • FETCH
  • Aliases

SQL Operators

SQL Operators" refers to the fundamental symbols and keywords within the SQL that enable users to perform various operations. Operators let you build complex query conditions.

  • AND Operator
  • OR Operator
  • Logical Operators
  • LIKE Operator
  • IN Operator
  • NOT Operator
  • NOT EQUAL Operator
  • IS NULL Operator
  • UNION Operator
  • UNION ALL Operator
  • EXCEPT Operator
  • BETWEEN Operator
  • ALL and ANY
  • INTERSECT Operator
  • EXISTS Operator
  • CASE Operator

SQL Aggregate Functions

Whether you are calculating the total sales revenue for a particular product, finding the average age of customers, or determining the highest value in a dataset, SQL Aggregate Functions make these tasks straightforward and manageable.

  • Aggregate Function
  • Count() Function
  • SUM() Function
  • MIN() Function
  • MAX() Function
  • AVG() Function

Data Constraints

Constraints act as rules or conditions imposed on the data, dictating what values are permissible and what actions can be taken. They play a crucial role in maintaining the quality and coherence of the database by preventing errors.

  • NOT NULL Constraints
  • Primary Key Constraints
  • Foreign Key Constraints
  • Composite Key
  • Unique Constraints
  • Alternate Key
  • CHECK Constraints
  • DEFAULT Constraints

SQL Joins

SQL joins serve as the weaver's tool, allowing you to seamlessly merge data from multiple tables based on common threads. So explore this section to learn how to use JOIN command.

  • JOIN
  • Outer Join
  • Left Join
  • Right Join
  • Full Join
  • Cross Join
  • Self Join
  • UPDATE with JOIN
  • DELETE JOIN
  • Recursive Join

SQL Functions

SQL functions offer an efficient and versatile approach to data analysis. Enhance your queries with built-in functions that manipulate data types and perform calculations.

  • Date Functions
  • String Functions
  • Numeric Functions
  • Statistical Functions
  • JSON Functions
  • Conversion Functions
  • Datatype Functions
  • LTRIM Function
  • UPPER Function
  • RTRIM Function

SQL Views

Views simplify complex queries and improve security by controlling data access. Views also act like a helpful security guard, keeping the most sensitive information in the back room, while still allowing access to what's needed.

  • CREATE VIEW
  • UPDATE VIEW
  • RENAME VIEW
  • DROP VIEW

SQL Indexes

Improve query performance by creating indexes that speed up data retrieval.

  • Indexes
  • Create Index
  • Drop Index
  • Show Indexes
  • Unique Index
  • Clustered Index vs Non-Clustered Index

SQL Subquery

Perform queries within queries to solve complex data retrieval problems. They help in filtering data or performing operations on data that would otherwise require multiple queries.

  • Subquery
  • Correlated Subqueries
  • Nested Queries

Miscellaneous Topics

Explore advanced and useful SQL concepts to deepen your knowledge

  • Wildcards Operators
  • Comments
  • Pivot and Unpivot
  • Trigger
  • Hosting
  • Performance Tuning
  • Stored Procedures
  • Transactions
  • Sub Queries
  • Using Sequences
  • Auto Increment
  • Window functions
  • Cursors
  • Common Table Expressions
  • Database Tuning
  • Dynamic
  • Regular Expressions

Exercises, Interview Questions & Cheat Sheet

This section provides practical exercises and commonly asked interview questions to help strengthen your SQL knowledge. It also includes a cheat sheet for quick reference, making SQL concepts easier to grasp.

  • Exercises
  • Quiz
  • Interview Questions
  • Query Interview Questions
  • Cheat Sheet
  • 30 Days of SQL – From Basic to Advanced

Advanced SQL & Databases

Advanced SQL topics explore techniques like optimization, complex joins, and working with large-scale databases. This section also covers the use of advanced functions and stored procedures to handle advanced database operations.

Database Design and Modeling

Database design focuses on creating an efficient database structure that is scalable and meets user requirements. Modeling involves defining relationships, entities, and constraints to ensure data integrity and efficient querying.

  • Introduction of ER Model
  • How to Draw Entity Relationship Diagrams (ERDs)
  • Mapping from ER Model to Relational Model
  • Introduction of Database Normalization
  • Functional Dependency and Attribute Closure
  • Types of Functional dependencies
  • Rules of Inference
  • Normal Forms in DBMS
  • Denormalization in Databases
  • Database Design

Database Security

Database security protects data from unauthorized access, corruption, and breaches. It includes encryption, authentication, and user privilege management to safeguard sensitive information stored in databases.

  • Injection
  • Types of SQL Injection
  • Data Encryption
  • Database Recovery Techniques in DBMS
  • Backup
  • How to Restore SQL Server Database From Backup?

Database Connectivity

Database connectivity enables applications to interact with databases through established protocols and drivers. This section covers how to establish secure connections and manage database interactions in programming languages like PHP, Python, and Java.

  • ORM (Object-Relational Mapping)
  • ODM (Object-Document Mapping)
  • ODBC (Open Database Connectivity)

Career & Job Opportunities in SQL

While SQL is a key skills for various roles in the tech industry, but it is important to understand that most of the positions listed below require more than just SQL knowledge. To increase your chances of landing high paying roles at top companies, you should have strong foundation in other databases, Data Management tools and related technologies.

Here we have listed the best career opportunities anyone can pursue after learning SQL.

Career RoleAverage Salary (INR) per AnnumAverage Salary (USD) per Annum
SQL Developer₹4,50,000 – ₹11,30,000$84,276 – $153,107
Database Administrator (DBA)₹4,00,000 – ₹10,00,000$90,000 – $131,060
Data Analyst₹4,00,000 – ₹9,00,000$85,500
Data Scientist₹8,00,000 – ₹25,00,000$70,000 – $130,000
ETL Developer₹6,00,000 – ₹14,00,000$85,500
Business Intelligence (BI) Developer₹7,00,000 – ₹20,00,000$107,870
SQL Server Developer₹5,50,000 – ₹13,00,000$104,864
Big Data Engineer₹10,00,000 – ₹30,00,000$125,003 – $300,000
Software Consultant₹7,00,000 – ₹20,00,000$100,000 – $150,000
.NET Developer (with SQL)₹4,50,000 – ₹12,00,000$100,000 – $120,000

Applications of SQL

SQL plays an important role in data-driven industries where efficient database management is crucial. Its versatility makes it applicable in various architectural models and operational domains, including:

  • Client/Server Architecture: Connects front-end and back-end systems for smooth data exchange.
  • Three-Tier Architecture: Supports interaction between client, application server, and database.
  • Data Definition Language (DDL): Create, modify, and delete database structures.
  • Data Manipulation Language (DML): Insert, update, delete, and retrieve data.
  • Data Control Language (DCL): Manage database access and security permissions.

Latest Trend [2025]: SQL Server 2025 introduces AI-driven features directly within the SQL engine. It supports native vector data types and AI model management, allowing developers to run AI tasks directly in SQL without external tools.

Quick Links:

  • SQL | Multiple Choice Questions
  • SQL | Interview Questions
  • SQL Interview Questions | Set 1
  • SQL Interview Questions | Set 2
  • SQL | Commonly asked DBMS interview questions | Set 1
  • SQL | Commonly asked DBMS interview questions | Set 2

Introduction to SQL
Visit Course explore course icon
Video Thumbnail

Introduction to SQL

Video Thumbnail

Data Retrieval with SQL

Video Thumbnail

Introduction to Keys

Video Thumbnail

Insert Data in a table

Video Thumbnail

Update data from a table

Video Thumbnail

SQL in Action

Next Article
What is SQL?

K

kartik
Improve
Article Tags :
  • SQL
  • Databases
  • DBMS-SQL

Similar Reads

    SQL Tutorial
    Structured Query Language (SQL) is the standard language used to interact with relational databases. Whether you want to create, delete, update or read data, SQL provides the structure and commands to perform these operations. SQL is widely supported across various database systems like MySQL, Oracl
    8 min read

    Basics

    What is SQL?
    SQL was invented in the 1970s by IBM and was first commercially distributed by Oracle. The original name was SEQUEL (Structured English Query Language), later shortened to SQL. It is a standardized programming language used to manage, manipulate and interact with relational databases. It allow users
    9 min read
    SQL Data Types
    SQL Data Types are very important in relational databases. It ensures that data is stored efficiently and accurately. Data types define the type of value a column can hold, such as numbers, text, or dates. Understanding SQL Data Types is critical for database administrators, developers, and data ana
    5 min read
    SQL Operators
    SQL operators are important in DBMS as they allow us to manipulate and retrieve data efficiently. Operators in SQL perform arithmetic, logical, comparison, bitwise, and other operations to work with database values. Understanding SQL operators is crucial for performing complex data manipulations, ca
    5 min read
    SQL Commands | DDL, DQL, DML, DCL and TCL Commands
    SQL commands are crucial for managing databases effectively. These commands are divided into categories such as Data Definition Language (DDL), Data Manipulation Language (DML), Data Control Language (DCL), Data Query Language (DQL), and Transaction Control Language (TCL). In this article, we will e
    7 min read
    SQL Database Operations
    SQL databases or relational databases are widely used for storing, managing and organizing structured data in a tabular format. These databases store data in tables consisting of rows and columns. SQL is the standard programming language used to interact with these databases. It enables users to cre
    3 min read
    SQL CREATE TABLE
    In SQL, creating a table is one of the most essential tasks for structuring your database. The CREATE TABLE statement defines the structure of the database table, specifying column names, data types, and constraints such as PRIMARY KEY, NOT NULL, and CHECK. Mastering this statement is fundamental to
    5 min read

    Queries & Operations

    SQL SELECT Query
    The SQL SELECT query is one of the most frequently used commands to retrieve data from a database. It allows users to access and extract specific records based on defined conditions, making it an essential tool for data management and analysis. In this article, we will learn about SQL SELECT stateme
    4 min read
    SQL INSERT INTO Statement
    The SQL INSERT INTO statement is one of the most essential commands for adding new data into a database table. Whether you are working with customer records, product details or user information, understanding and mastering this command is important for effective database management. How SQL INSERT I
    6 min read
    SQL UPDATE Statement
    In SQL, the UPDATE statement is used to modify existing records in a table. Whether you are updating a single record or multiple records at once, SQL provides the necessary functionality to make these changes. Whether you are working with a small dataset or handling large-scale databases, the UPDATE
    6 min read
    SQL DELETE Statement
    The SQL DELETE statement is an essential command in SQL used to remove one or more rows from a database table. Unlike the DROP statement, which removes the entire table, the DELETE statement removes data (rows) from the table retaining only the table structure, constraints, and schema. Whether you n
    4 min read
    SQL | WHERE Clause
    The SQL WHERE clause allows filtering of records in queries. Whether you are retrieving data, updating records, or deleting entries from a database, the WHERE clause plays an important role in defining which rows will be affected by the query. Without WHERE clause, SQL queries would return all rows
    4 min read
    SQL | Aliases
    In SQL, aliases are temporary names assigned to columns or tables for the duration of a query. They make the query more readable, especially when dealing with complex queries or large datasets. Aliases help simplify long column names, improve query clarity, and are particularly useful in queries inv
    4 min read

    SQL Joins & Functions

    SQL Joins (Inner, Left, Right and Full Join)
    SQL joins are fundamental tools for combining data from multiple tables in relational databases. Joins allow efficient data retrieval, which is essential for generating meaningful observations and solving complex business queries. Understanding SQL join types, such as INNER JOIN, LEFT JOIN, RIGHT JO
    5 min read
    SQL CROSS JOIN
    In SQL, the CROSS JOIN is a unique join operation that returns the Cartesian product of two or more tables. This means it matches each row from the left table with every row from the right table, resulting in a combination of all possible pairs of records. In this article, we will learn the CROSS JO
    3 min read
    SQL | Date Functions (Set-1)
    SQL Date Functions are essential for managing and manipulating date and time values in SQL databases. They provide tools to perform operations such as calculating date differences, retrieving current dates and times and formatting dates. From tracking sales trends to calculating project deadlines, w
    5 min read
    SQL | String functions
    SQL String Functions are powerful tools that allow us to manipulate, format, and extract specific parts of text data in our database. These functions are essential for tasks like cleaning up data, comparing strings, and combining text fields. Whether we're working with names, addresses, or any form
    7 min read

    Data Constraints & Aggregate Functions

    SQL NOT NULL Constraint
    In SQL, constraints are used to enforce rules on data, ensuring the accuracy, consistency, and integrity of the data stored in a database. One of the most commonly used constraints is the NOT NULL constraint, which ensures that a column cannot have NULL values. This is important for maintaining data
    3 min read
    SQL PRIMARY KEY Constraint
    The PRIMARY KEY constraint in SQL is one of the most important constraints used to ensure data integrity in a database table. A primary key uniquely identifies each record in a table, preventing duplicate or NULL values in the specified column(s). Understanding how to properly implement and use the
    5 min read
    SQL Count() Function
    In the world of SQL, data analysis often requires us to get counts of rows or unique values. The COUNT() function is a powerful tool that helps us perform this task. Whether we are counting all rows in a table, counting rows based on a specific condition, or even counting unique values, the COUNT()
    7 min read
    SQL SUM() Function
    The SUM() function in SQL is one of the most commonly used aggregate functions. It allows us to calculate the total sum of a numeric column, making it essential for reporting and data analysis tasks. Whether we're working with sales data, financial figures, or any other numeric information, the SUM(
    5 min read
    SQL MAX() Function
    The MAX() function in SQL is a powerful aggregate function used to retrieve the maximum (highest) value from a specified column in a table. It is commonly employed for analyzing data to identify the largest numeric value, the latest date, or other maximum values in various datasets. The MAX() functi
    4 min read
    AVG() Function in SQL
    SQL is an RDBMS system in which SQL functions become very essential to provide us with primary data insights. One of the most important functions is called AVG() and is particularly useful for the calculation of averages within datasets. In this, we will learn about the AVG() function, and its synta
    4 min read

    Advanced SQL Topics

    SQL | Subquery
    In SQL, subqueries are one of the most powerful and flexible tools for writing efficient queries. A subquery is essentially a query nested within another query, allowing users to perform operations that depend on the results of another query. This makes it invaluable for tasks such as filtering, cal
    6 min read
    Window Functions in SQL
    SQL window functions are essential for advanced data analysis and database management. It is a type of function that allows us to perform calculations across a specific set of rows related to the current row. These calculations happen within a defined window of data and they are particularly useful
    6 min read
    SQL Stored Procedures
    Stored procedures are precompiled SQL statements that are stored in the database and can be executed as a single unit. SQL Stored Procedures are a powerful feature in database management systems (DBMS) that allow developers to encapsulate SQL code and business logic. When executed, they can accept i
    7 min read
    SQL Triggers
    SQL triggers are essential in database management systems (DBMS). They enable SQL statements to run when specific database events occur such as when someone adds, changes, or removes data. Triggers are commonly used to maintain data integrity, track changes, and apply business rules automatically, w
    7 min read
    SQL Performance Tuning
    SQL performance tuning is an essential aspect of database management that helps improve the efficiency of SQL queries and ensures that database systems run smoothly. Properly tuned queries execute faster, reducing response times and minimizing the load on the serverIn this article, we'll discuss var
    8 min read
    SQL TRANSACTIONS
    SQL transactions are essential for ensuring data integrity and consistency in relational databases. Transactions allow for a group of SQL operations to be executed as a single unit, ensuring that either all the operations succeed or none of them do. Transactions allow us to group SQL operations into
    8 min read

    Database Design & Security

    Introduction of ER Model
    The Entity-Relationship Model (ER Model) is a conceptual model for designing a databases. This model represents the logical structure of a database, including entities, their attributes and relationships between them. Entity: An objects that is stored as data such as Student, Course or Company.Attri
    10 min read
    Introduction of Database Normalization
    Normalization is an important process in database design that helps improve the database's efficiency, consistency, and accuracy. It makes it easier to manage and maintain the data and ensures that the database is adaptable to changing business needs.Database normalization is the process of organizi
    8 min read
    SQL Injection
    SQL Injection is a security flaw in web applications where attackers insert harmful SQL code through user inputs. This can allow them to access sensitive data, change database contents or even take control of the system. It's important to know about SQL Injection to keep web applications secure.In t
    7 min read
    SQL Data Encryption
    In today’s digital era, data security is more critical than ever, especially for organizations storing the personal details of their customers in their database. SQL Data Encryption aims to safeguard unauthorized access to data, ensuring that even if a breach occurs, the information remains unreadab
    5 min read
    SQL Backup
    In SQL Server, a backup, or data backup is a copy of computer data that is created and stored in a different location so that it can be used to recover the original in the event of a data loss. To create a full database backup, the below methods could be used : 1. Using the SQL Server Management Stu
    4 min read
    What is Object-Relational Mapping (ORM) in DBMS?
    Object-relational mapping (ORM) is a key concept in the field of Database Management Systems (DBMS), addressing the bridge between the object-oriented programming approach and relational databases. ORM is critical in data interaction simplification, code optimization, and smooth blending of applicat
    7 min read
`; $(commentSectionTemplate).insertBefore(".article--recommended"); } loadComments(); }); }); function loadComments() { if ($("iframe[id*='discuss-iframe']").length top_of_element && top_of_screen articleRecommendedTop && top_of_screen articleRecommendedBottom)) { if (!isfollowingApiCall) { isfollowingApiCall = true; setTimeout(function(){ if (loginData && loginData.isLoggedIn) { if (loginData.userName !== $('#followAuthor').val()) { is_following(); } else { $('.profileCard-profile-picture').css('background-color', '#E7E7E7'); } } else { $('.follow-btn').removeClass('hideIt'); } }, 3000); } } }); } $(".accordion-header").click(function() { var arrowIcon = $(this).find('.bottom-arrow-icon'); arrowIcon.toggleClass('rotate180'); }); }); window.isReportArticle = false; function report_article(){ if (!loginData || !loginData.isLoggedIn) { const loginModalButton = $('.login-modal-btn') if (loginModalButton.length) { loginModalButton.click(); } return; } if(!window.isReportArticle){ //to add loader $('.report-loader').addClass('spinner'); jQuery('#report_modal_content').load(gfgSiteUrl+'wp-content/themes/iconic-one/report-modal.php', { PRACTICE_API_URL: practiceAPIURL, PRACTICE_URL:practiceURL },function(responseTxt, statusTxt, xhr){ if(statusTxt == "error"){ alert("Error: " + xhr.status + ": " + xhr.statusText); } }); }else{ window.scrollTo({ top: 0, behavior: 'smooth' }); $("#report_modal_content").show(); } } function closeShareModal() { const shareOption = document.querySelector('[data-gfg-action="share-article"]'); shareOption.classList.remove("hover_share_menu"); let shareModal = document.querySelector(".hover__share-modal-container"); shareModal && shareModal.remove(); } function openShareModal() { closeShareModal(); // Remove existing modal if any let shareModal = document.querySelector(".three_dot_dropdown_share"); shareModal.appendChild(Object.assign(document.createElement("div"), { className: "hover__share-modal-container" })); document.querySelector(".hover__share-modal-container").append( Object.assign(document.createElement('div'), { className: "share__modal" }), ); document.querySelector(".share__modal").append(Object.assign(document.createElement('h1'), { className: "share__modal-heading" }, { textContent: "Share to" })); const socialOptions = ["LinkedIn", "WhatsApp","Twitter", "Copy Link"]; socialOptions.forEach((socialOption) => { const socialContainer = Object.assign(document.createElement('div'), { className: "social__container" }); const icon = Object.assign(document.createElement("div"), { className: `share__icon share__${socialOption.split(" ").join("")}-icon` }); const socialText = Object.assign(document.createElement("span"), { className: "share__option-text" }, { textContent: `${socialOption}` }); const shareLink = (socialOption === "Copy Link") ? Object.assign(document.createElement('div'), { role: "button", className: "link-container CopyLink" }) : Object.assign(document.createElement('a'), { className: "link-container" }); if (socialOption === "LinkedIn") { shareLink.setAttribute('href', `https://www.linkedin.com/sharing/share-offsite/?url=${window.location.href}`); shareLink.setAttribute('target', '_blank'); } if (socialOption === "WhatsApp") { shareLink.setAttribute('href', `https://api.whatsapp.com/send?text=${window.location.href}`); shareLink.setAttribute('target', "_blank"); } if (socialOption === "Twitter") { shareLink.setAttribute('href', `https://twitter.com/intent/tweet?url=${window.location.href}`); shareLink.setAttribute('target', "_blank"); } shareLink.append(icon, socialText); socialContainer.append(shareLink); document.querySelector(".share__modal").appendChild(socialContainer); //adding copy url functionality if(socialOption === "Copy Link") { shareLink.addEventListener("click", function() { var tempInput = document.createElement("input"); tempInput.value = window.location.href; document.body.appendChild(tempInput); tempInput.select(); tempInput.setSelectionRange(0, 99999); // For mobile devices document.execCommand('copy'); document.body.removeChild(tempInput); this.querySelector(".share__option-text").textContent = "Copied" }) } }); // document.querySelector(".hover__share-modal-container").addEventListener("mouseover", () => document.querySelector('[data-gfg-action="share-article"]').classList.add("hover_share_menu")); } function toggleLikeElementVisibility(selector, show) { document.querySelector(`.${selector}`).style.display = show ? "block" : "none"; } function closeKebabMenu(){ document.getElementById("myDropdown").classList.toggle("show"); }
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences