Posts

Showing posts with the label Mysql

MYSQL - “LIKE operator”

Image
  MYSQL - “LIKE operator” The LIKE operator is used in a WHERE clause to search for a pattern in a column. Two wildcards are often used while using the LIKE operator: Percentage sign( % ) — it represents multiple characters ,zero ,one. Underscore sign( _ ) — it represents single character. Create database before creating a table. commands : CREATE DATABASE pannts_db, USE pants_db creating pants_db table and inserting values LIKE ‘J%’ — finds any value that starts with “J” In the below syntax it shows the values from “ Article column ” where the value starts with “J” .  LIKE ‘J%’.  It shows only those values as per the condition described. LIKE ’J%’ LIKE ‘%e’ — finds any values that ends with “e” In the below syntax it shows the values from “ color column ” where the value ends with the letter ”e”.  LIKE ‘%e’.  It shows only those rows as per the condition described. LIKE ‘%e’ LIKE ‘%a%’ — finds any values that have or in any position. In the below syntax it show...

MYSQL Basics to Know…..PART-3

Image
  MYSQL Basics to Know…..PART-3 AGGREGATE FUNCTIONS — collects a set of values to return a single value. I have used my favorite comic data in creating a database and a table. The Vision, Volume 1: Little Worse Than A Man Batman: The killing Joke Venom, Volume 1: Homecoming Venom, Volume 2: The Abyss The Flash: A Celebration of 75 Years COUNT() : counts the number of rows in a database. COUNT() syntax COUNT() syntax MIN() : It shows the lowest number of values in a table. MIN() syntax MAX() : It shows the highest number of values in a table. MAX() syntax For MIN Title and pages . In this below syntax, it shows only Title and pages which is in ascending order and has a LIMIT -1 (which gives only 1 row of data). For MIN Title and pages The below syntax is based on descending order which can be also used for  MAX() syntax . ORDER BY() SUM() : It calculates the sum of a selected set of columns. SUM() syntax AVG() : It calculates the average of a selected set of columns. AVG() synt...

MYSQL Basics to know….PART -1

Image
  MYSQL Basics to know….PART -1 MYSQL -It is a Cross-Platform, Open-Source, Relational Database management system and free Application. The data in a row is called “ Record ” The data in a column is called “ Field ” CREATE DATABASE  -Creates a database in the server. USE  command -Switch to the database with specified name. CREATE TABLE  -Creates a entire database objects table. Syntax: CREATE TABLE shirts1(shirts_id INT NOT NULL AUTO_INCREMENT,Article VARCHAR(100),color VARCHAR(100), shirt_size VARCHAR(100),last_worn INT, PRIMARY KEY (shirts_id)); DESC(DESCRIBE)  command-To see Database Field formats. SELECT  command -Extracts Data from a Database. Over here Asterisk “ * “ it selects all the columns from the table. INSERT INTO  command-Inserts data into the tables. WHERE  command -Is used for Filtering the records(rows). UPDATE  command- If you want to change any new Value/data to be added up in the table can use the UPDATE command. Updates ...

MYSQL- Joining Tables with Inner Join statement

Image
  MYSQL- Joining Tables with Inner Join statement MYSQL is a widely used relational database management system (RDMS). It is an open-source application. A “Join statement” is used to combine rows from two or more tables, based on a related column between them. 👉INNER JOIN -Returns records that have matching values in both tables. ✅Generating Random Data for the scheme. Creating  EMPLOYEE  and  EMPLOYEE DEPARTMENT Tables  and inserting values by using a few MYSQL Commands. 🔷Using MYSQL Commands and Data types for creating an Employee Table. CREATE DATABASE  — creates a new database. CREATE TABLE - creates a new table. USE  — selects a simple database and then performs operations on it using the in-built commands. INSERT INTO  — inserts new data into a database. INT  — Integer numerical (no decimal). VARCHAR  — data type stores variable-length character strings. INNER JOIN  — selects records that have matching values in both tables....

Types of MYSQL JOINS

Image
  Types of MYSQL JOINS A “Join statement” is used to combine rows from two or more tables, based on a related column between them.             🔲Do check the previous Article about INNER JOIN ⚡Created Random data and experimented with different JOINS. 👉Different Types of SQL JOINs to fetch data: INNER JOIN LEFT JOIN RIGHT JOIN CROSS JOIN SELF JOIN 🔹Used MYSQL Commands and Data types: CREATE TABLE - creates a new table. SELECT  — is used to select data from a database. INSERT INTO  — inserts new data into a database. LEFT OUTER JOIN (or) LEFT JOIN — this type of Join would fetch all the rows (including NULL values) from the table which is on the left side of the JOIN query. RIGHT OUTER JOIN (or) RIGHT JOIN— in this type of Join all the records that do not match from the right table are returned with NULL values on the columns for the left side table. UPDATE  — the statement is used to modify the existing records in a table. ALTER T...