SQL Basics 1

Download as pdf
Download as pdf
You are on page 1of 9
9116123, 134 AM MySa. Basics IW mysqutuTorIAL MySQL Basics This MySQL basics section teaches you how to use SQL statements to manage data in MySQL. It'll provide you with everything you need to know to work with MySQL effectively. Section 1. Querying data © SELECT FROM (ntips//wwvmysqltutorial org/mysq|-select-statement-query-data.aspx) — show you how to use simple SELECT FROM statement to query the data from a single table. © SELECT (hitpsy//www.mysqltutorial.org/mysql-basics/mysal-select)|~ learn how to use the SELECT statement without referencing a table, Section 2. Sorting data © ORDER BY (hitpsi//wuw.mysqltutorial.org/mysql-order-by/) - show you how to sort the result set using ORDER 8Y clause. The custom sort order with the FIELD function will be also covered. Section 3. Filtering data © WHERE (https://www.mysqltutorial.org/mysql-where/) — learn how to use the WHERE clause to filter rows based on specified conditions. © SELECT DISTINCT (https//wwwmysqjtutoriaorg/mysql-distinct.aspy) — show you how to use the DISTINCT operator in the SELECT statement to eliminate duplicate rows in a result set. © AND (httpsi//www.mysqltutorialorg/mysql-and/) — introduce you to the aND operator to combine Boolean expressions to form a complex condition for filtering data. tps saw. mysetutorialorgimysa-basics! 19 9116123, 134 AM MySa. Basics © OR (hitps//www mysqltutorialorg/mysql-or/ — introduce you to the oR operator and show you how to combine the oR operator with the AND operator to filter data. © IN. (bttpsy//wmmmysqltutorialorg/mysql-basics/mysql-in/) — Show you how to use the IN operator in the were clause to determine if a value matches any value in a set. © NOT IN (httpsy//www mysqltutorialorg/mysql-basics/mysql-not-inf) ~ negate the IN operator using the NOT operator to check if a value doesn’t match any value in a set. © BETWEEN (hitps/mww.mysaltutorialorg/mysql-between) — show you how to query data based on a range using BETWEEN operator. © LIKE. (htpsy/mww.mysqtutorialora/mysql-tike/ ~ provide you with technique to query data based on a pattern. © LIMIT (htpsi/muw.mysatutorialorg/mysqlimitaspx) - US@ LINIT to constrain the number of rows returned by SELECT statement © IS NULL (heps/awww.mysetuterialorg/mysql-is-nul/)~ test whether a value is NULL or not by using IS NULL operator. Section 4. Joining tables Table & Column Aliases (https://www.mysqltutorial.org/mysql-alias/) — introduce you to table and column aliases. © Joins (hitps://wuw.mysqltutoriaLorg/mysql-join) — give you an overview of joins supported in MySQL including inner join, left join, and right join © INNER JOIN (httpsi/mwvimyseltutorial.org/mysql-inner-join.aspx) ~ query rows from a table that has matching rows in another table. © LEFT JOIN (hitps//wmwmysqltutorial.org/mysql-lettjoinasps) ~ return all rows from the left table and matching rows from the right table or null if no matching rows found in the right table. © RIGHT JOIN (hetpsi/-www.mysqltutorialorg/mysal-right-jiny) — return all rows from the right table and matching rows from the left table or null if no matching rows found in the left table. tps iva. mysetutorialorgimysa-basies! 29 9118723, 124M MySl Basis © CROSS JOIN (hitpsi/wmysqltutoriaorg/mysql-cross-join/) ~ make a Cartesian product of rows from multiple tables, # Self-join (hitpsi/iwmysqtutorialorg/mysq|-selt-join/) — join a table to itself using table alias and connect rows within the same table using inner join and left join. Section 5. Grouping data © GROUP BY (https:/www.mysqltutorialorg/mysql-group-byaspx) - show you how to group rows into groups based on columns or expressions. © HAVING (netpsi//mwwmyseltutorialorg/mysal-having.aspx) ~ filter the groups by a specific condition © ROLLUP (hetpsi//www.mysqltutorialorg/mysl-rellup/)— generate multiple grouping sets considering a hierarchy between columns specified in the Group BY clause. Section 6. Subqueries © Subquery (https://www.mysqltutorial.ora/mysql-subquery/) - show you how to nest a query (inner query) within another query (outer query) and use the result of the inner query for the outer query. © Derived table (htips//ww.mysqltutorialorg/mysal-derived-table/) ~ introduce you to the derived table concept and show you how to use it to simplify complex queries, © EXISTS (htps/mwmysgtuterialorg/mysal-exists) ~ test for the existence of rows Section 7. Common Table Expressions © Common Table Expression or CTE (hitpsi//www.mysqltutorial.rg/mysql-cte/) ~ explain to you the common table expression concept and show you how to use CTE for querying data from hitps iw. mysetutorialorgimysa-basies! si 9116123, 134 AM MySa. Basics tables. © Recursive CTE (hetps:/mmmysaltutorialorg/myscl-recursive-cte/)— use the recursive CTE to traverse the hierarchical data. Section 8. Set operators © UNION and UNION ALL (hitps:/www.mysaitutorial org/sql-union-mysqlaspx) — combine two or more result sets of multiple queries into a single result set. ‘® INTERSECT (httpsi//ww.mysqltutoriaLorg/mysql-intersect/)— show you a couple of ways to simulate the INTERSECT operator. ‘® MINUS (hetps//mwzmysalturoral.org/mysal-minus/) ~ explain to you the SQL MINUS operator and show you how to simulate it. Section 9. Modifying data in MySQL In this section, you will learn how to insert, update, and delete data from tables using various MySQL statements. INSERT (nttpsy/wmwmysqltutorialorg/mysql-insert-statementaspy)= use various forms of the INSERT statement to insert data into a table. ‘® INSERT Multiple Rows (httosi//www.mysqltutorial org/mysql-insert-multiple-rows/) ~ insert multiple rows into a table. ‘® INSERT INTO SELECT (hitps,/Aww.mysqitutorial org/mysql-insert-into-select/)~ insert data into a table from the result set of a query. @ INSERT IGNORE (httpsi//www.mysqltutorial ora/mysql-insert-ignore/) ~ explain you the INSERT IGNORE statement that inserts rows into a table and ignores rows that cause errors. tps iw. mysetutorialorgimysa-basis! 49 911823, 134M MySal Basics * UPDATE (https//mwumysaltutoriaLorg/mysal-update-data.aspx) — learn how to use UPDATE statement and its options to update data in database tables. ‘© UPDATE JOIN (hitpsi//mwumysaltutoriaLorg/mysal-update-join/) ~ show you how to perform cross- table update using upoate 301N statement with INnneR JOIN and Lert JOIN ‘© DELETE (nttpsi//mm.mysqltutorialorg/mysql-delete-statementaspx)— show you how to use the DELETE statement to delete rows from one or more tables. © ON DELETE CASCADE (https://www.mysqltutorial.org/mysql-on-delete-cascade/) — learn how to use ON DELETE CASCADE referential action for a foreign key to delete data from a child table automatically when you delete data from a parent table. ‘® DELETE JOIN (hitpsi//www.mysqltutoriaorg/iysql-delete-join/)— show you how to delete data from multiple tables. ® REPLACE (httpsi//wnwwmysaltutorial.org/mysal-replace.aspx) — learn how to insert or update data depends on whether data exists in the table or not. ‘* Prepared Statement (https:/Awwwmysqltutoriaorg/mysql-prepared-statementasox) - show you how to use the prepared statement to execute a query, Section 10. MySQL transaction '® Transaction (hreps:/waw.mysqltutoria.org/mysql-transaction aspx) ~ learn about MySQL transactions, and how to use CONT and ROLLBACK to manage transactions in MySQL. © Table locking (nttps:/wmw.mysqltutorialorg/myse|-table-locking/) ~ learn how to use MySQL locking for cooperating table access between sessions. Section 11. Managing databases This section shows you how to manage MySQL databases. tps saw. mysetutorialorgimysa-basies! 89 971625, 194aM MySl Basis * Selecting a MySQL database (https//ww.mysq|tutorialorg/mysql-select-database/) - show you how to use the USE statement to set the current database. © CREATE DATABASE (https://www mysqltutorial org/mysql-cteate-database/) — show you step by step how to create a new database in MySQL Server. ‘® DROP DATABASE (httpss/iwuw.mysqltutorialorg/mysql-drop-database/) — walk you through the steps of deleting a database from the database server. Section 12. Working with tables This section shows you how to manage the most important database objects in MySQL, including databases and tables. MySQL storage engines (https://www.mysqltutorial.org/understand-mysql-table-types-innodb-myisam.aspx) = itis essential to understand the features of each storage engine so that you can use them effectively to maximize the performance of your databases. ‘© CREATE TABLE (hitps:/www.mysaltutorialorg/mysql-create-table/) — show you how to create new tables in a database using CREATE TABLE statement. AUTO_INCREMENT (https://www.mysqitutorial.org/mysql-sequence/) - show you how to use an AUTO_INCREMENT column generate unique numbers automatically for the primary key. © ALTER TABLE (https:/w.mysqltutorialorg/mysql-alter-table aspx) — learn how to change the structure ofa table using the ALTER TABLE statement. ‘® Renaming tables (atps/wmwmysaltutorialorg/mysql-rename-table/) — show you how to rename a table using RENAME TABLE statement. ‘® Removing a column from a table (attps//mww.mysaltutorial org/mysql-drop-column/) ~ show you how touse the ALTER TABLE DROP COLUMN statement to remove one or more columns from a table. ‘© Adding a new column to a table (httpsi/amwimysqitutorialorg/mysal-add-column/ = show you how to add one or more columns to an existing table using ALTER TABLE ADD COLUMN statement. tps saw. mysetutorialorgimysa-basies! 69 911823, 134M MySQ1 Basics ‘* DROP TABLE (hitps//www mysqitutorialorg/mysal-drop-table) - show you how to remove existing tables using DROP TABLE statement. ‘© Temporary tables (hitps:/wuw.mysqltutorial org/mysql-temporary-table/ ~ discuss MySQL temporary tables and show you how to manage temporary tables effectively. ‘® TRUNCATE TABLE (httpsi//www.mysqltutorial.rg/mysql-truncate-table/) - show you how to delete all data from a table fast and more efficient using the TRUNCATE TABLE statement. © Generated columns (https//www.mysqltutorialorg/mysal-generated-columns/) - guide you on how to use the generated columns to store data computed from an expression or other columns. Section 13. MySQL data types MySQL data types (hitps:/waw mysqltutorial.org/mysql-data-types.aspx) - show you various data types in MySQL so that you can apply them effectively in designing database tables. ‘® INT (oetpsi//wwmysqltutorialorg/imysql-int/) ~ show you how to use integer data type. ® DECIMAL (https://mww.mysqltutorial.org/mysql-decimal/) = show you how to use DECIMAL datatype to store exact values in decimal format. © BIT (htpsi/www.mysq|tutorialorg/mysql-bit))— introduce you SIT datatype and how to store bit values in MySQL. ‘® BOOLEAN (nxtpsi//mwwmysqltutorialorg/mysql-boolean/) = explain to you how MySQL handles Boolean values by using TINYINT(2) internally © CHAR (httpsi/wwmysqitutorialorg/mysql-char-data-type/)—a guide to Chak data type for storing the fixed-length string, © VARCHAR (https//wmwmysqltutorial.org/mysql-varchar/)— give you the essential guide to vaRcHAaR datatype. ‘© TEXT (hitps//mwwmysqltutorialorg/mysql-text)) — show you how to store text data using TEXT datatype. tps saw. mysetutorialorgmysa-basies! 79 9118723, 134 AM MySal Basics © DATE (httos/mwwmysqltutorialorg/mysal-date/ ~ introduce you to the pate datatype and show you some date functions to handle the date data effectively. © TIME (hetpsv/www.mysqituterialorg/mysal-tiney) — walk you through the features of TIME datatype and show you how to use some useful temporal functions to handle time data. © DATETIME (attps://www.mysaltutorialorg/mysql-datetime/) — introduce you to the DATETIME datatype and some useful functions to manipulate DATETINE values. © TIMESTAMP (https//ww.mysqltutorial org/mysql-timestamp.aspx) ~ introduce you to TIMESTAMP and its features called automatic initialization and automatic update that allows you to define auto-initialized and auto-updated columns for a table. © JSON (hreps/iwwwmyseltutorial.org/mysql-json/) ~ show you how to use JSON data type to store JSON documents. © ENUM (https/mwmysqltutorial org/mysql-enum/ — learn how to use ENUM datatype correctly to store enumeration values. Section 14. MySQL constraints © NOT NULL (https//www.mysqltutoria.org/mysql-not-null-constraint/) ~ introduce you to the NOT NULL constraint and show you how to declare a NoT NULL column or add a NoT NULL constraint to an existing column. © Primary key (heps://uwwmysaltutoralora/mysal-primary-key?) — guide you on how to use the primary key constraint to create the primary key for a table. © Foreign key (https:/wmwmysqltutorial.org/mysql-foreign-key/) ~ introduce you to the foreign key and show you step by step how to create and drop foreign keys. © Disable foreign key checks (https//ww mysaltutorialorg/mysql-disable-foreign-key-checks/) - learn how to disable foreign key checks. © UNIQUE constraint (httpsi//www.mysqltutorial.org/mysql-unique-constraint/)— show you how to use UNIQUE constraint to enforce the uniqueness of values in a column or a group of columns in a table. tps iw. mysetutorialorgimys-basics! 89 9116123, 134 AM MySa. Basics © CHECK constraint (hitpsi//wuw.mysqltutorial org/mysql-check-constraint/) ~ learn how to create CHECK constraints to ensure data integrity. © DEFAULT (https://wnvw.mysqitutorialorg/mysql-basics/mysql-default/)— show you how to set a default value for a column using the DEFAULT constraint, © CHECK constraint emulation (https://wmw.mysqltutorial.org/mysql-check-constraint-emulation/) — if you use MySQL 8.0.15 or earlier version, you can emulate CHECK constraints using views or triggers. Section 15. MySQL globalization * Character Set (nttos:/amwmysaitutorialorg/mysal-character-sev/) ~ discuss character set and show you step by step how to perform various operations on character sets © Collation (hxtpsi//mww.mysqltutorialorg/mysal-collation) ~ discuss collation and show you how to set character sets and collations for the MySQL server, database, tables, and columns. Section 16. MySQL import & export CSV © Import CSV File Into MySQL Table (hrtps//mmw.mysaltutorialorg/imoort-csv-file-mysql-table/) — show you how to use LOAD DATA INFILE statement to import CSV file into a MySQL table. © Export MySQL Table to CSV (httpsi//www.mysqitutorial.org/mysql-export-table-to-csv/) — learn various techniques of how to export MySQL table to a CSV file format. Section 17. Advanced techniques © Natural sorting (httpsy/wuw.mysqltutoriaLorg/mysql-natural-sorting) — walk you through various natural sorting techniques in MySQL using the orDeR sy clause. tps iw. mysetutorialorgmysa-basics! 99

You might also like