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

Demystifying SQL vs. MySQL - Key Query Difference

Uploaded by

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

Demystifying SQL vs. MySQL - Key Query Difference

Uploaded by

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

SQL MysQL

SQL is a language used to " MySQL 0s an open-source RDBMS


that uses SQL.
manage relational databases.
SQL is a query language. " MySQL is a Relational Database
SQL 0s an ANSI/ISO standard. Management System (RDBMS).
" MySQL is not a standard; it
" SQL is a language with various
follows the SQL standard with
implementations. (e.g., MySQL,
some extensions.
PostgreSQL, SQLite).
" MySQL is one specific
SQL is a language specification; it
implementation of SQL.
is not owned by any company.
" MySQL is owned &managed by
SQL itself is nota software; it's a
Oracle Corporation.
language standard.
" MySQL is available under the GNU
SQL implementations may or may General Public License.
not support full-text search.
" MySQL has robust support for full
SQL provides features for text search.
concurrency control.
" MySQL includes mechanisms for
SQL does not dictate partitioning concurrency control.
methods; it depends on the " MySQL supports table partitioning
database system's features. for better performance.
ALL SQL Quari
SQL Query Query Description Example

SELECT Retrieves data from one or more SELECT name, age FROM users;
tables.

INSERT Adds new records to a table. INSERT INTO users (name, age) VALUES
('Alice', 30);

UPDATE Modifies existing records in a table. UPDATE users SET age = 31 WHERE name =
'Alice';

DELETE Removes records from a table. DELETE FROM users WHERE name = 'Alice';

CREATE Creates anew table in the database. CREATE TABLE users (id INT PRIMARY KEY,
TABLE name VARCHAR (100), age INT);
ALTER TABLE Modifies an existing table structure, ALTERTABLE users ADD email VARCHAR (100);'
such as adding or dropping
columns.

DROP TABLE Deletes a table and all its data. DROP TABLE users;

CREATE Creates a new database. CREATE DATABASE my_database;


DATABASE

DROP Deletes a database and all its data. DROP DATABASE my_database;'
DATABASE

SELECT Retrieves unique records from a SELECT DISTINCT age FRM users;
DISTINCT table.

WHERE Filters records that meet a specific SELECT name FROM users WHERE age > 25;
condition.
UNION Combines the result sets of two or *SELECT name FROM users UNION SELECT name

more SELECT queries. FROM employees;

UNION ALL Combines the result sets of two or SELECT name FROM users UNION ALL SELECT

more SELECT queries, including name FROM employees;


duplicates.

SUBQUERY A query nested inside another SELECT name FROM users WHERE age = (SELECT
query. MAX(age) FROM users);
EXISTS Checks if a subquery returns any SELECT name FROM users WHERE EXISTS (SELECT
records. 1 FROM orders WHERE users.id =
orders.user_id):

ANY Compares a value to any value in a 'SELECT name FROM users WHERE age > ANY
list or subquery. (SELECT age FROM users WHERE age < 30) ;

ALL Compares a value to all values in a SELECT name FROM users WHERE age> ALL
list or subquery. (SELECT age FROM users WHERE age < 30);

LIKE Searches for a specified pattern in a SELECT name FROM users WHERE name LIKE

column. 'A%';

IN Checks if a value is within a set of SELECT name FROM users WHERE age IN (25,
values. 30, 35);

BETWEEN Selects values within a range. 'SELECT name FROM users WHERE age BETWEEN 20
AND 30;

LIMIT Specifies the number of records to SELECT name FROM users LIMIT 5;
return.
WHERE Filters records that meet a specific SELECT name FROM users WHERE age > 25;
condition.

ORDER BY Sorts the result set by one or more *SELECT name, age FROM users ORDER BY age
columns. DESC;

GROUP BY Groups rows that have the same 'SELECT age, coUNT (*) FROM users GROUP BY
values into summary rows. age;

HAVING Filters groups based on a condition. SELECT age, couNT (*) FROM users GROUP BY
age HAVING COUNT (*) > 1;
JOIN Combines rows from two or more SELECT users.name, orders., amount FROM users
tables based on a related column. INNER JOIN orders ON users.id =
orders.user_id;
INNER JOIN Retrieves records with matching SELECT users.name, orders.amount FROM users
values in both tables. INNER JOIN orders ON users.id =
orders.user_id;
LEFT JOIN Retrieves all records from the left *SELECT users.name, orders.amount FROM users
table and matched records from the LEFT JOIN orders ON users.id =
right table. orders..user_ id;'

RIGHT JoIN Retrieves all records from the right SELECT users. name, orders. amount FROM users
table and matched records from the RIGHT JOIN orders ON users.id =
left table. orders.user_id;

FULL OUTER Retrieves records when there is a *SELECT users. name, orders.amount FROM users
JOIN match in one of the tables. FULL OUTER J0IN orders ON users.id =
orders. user_id;
LIMIT Specifies the number of records to 'SELECT name FROM users LIMIT 5;
return.

OFFSET Specifies the starting point for SELECT name FROM users LIMIT 5 OFFSET 10;
records to return.

TRUNCATE Removes all records from a table TRUNCATE TABLE users;


TABLE but retains the table structure.

CREATE Creates an index on a table to CREATE INDEX idx_name ON users (name);


INDEX improve query performance.
DROP INDEX Deletes an index from a table. DROP INDEX idx_name;
CASE Provides conditional logic in SQL SELECT name, age, CASE WHEN age < 30 THEN
queries. 'Young' ELSE '0ld' END as age_group FROM
users;

CAST Converts a value from one data type SELECT name, CAST (age AS CHAR) FROM users;
to another.

You might also like