Skip to content

Instantly share code, notes, and snippets.

View UtkarshYadav01's full-sized avatar

Utkarsh Yadav UtkarshYadav01

View GitHub Profile
-- REPLACE INTO SQL Demonstration
-- This script demonstrates how REPLACE INTO combines INSERT and DELETE operations
-- to simplify the process of updating or inserting records based on primary or unique key values.
-- Create and use database
CREATE DATABASE replace_demo;
USE replace_demo;
-- Create products table
CREATE TABLE products (
-- SQL DELETE Tutorial
-- Demonstrates how to remove records from a database table
-- DELETE FROM table_name WHERE condition;
-- Create a database for our examples
CREATE DATABASE delete_tutorial;
-- Use the database
USE delete_tutorial;
-- =============================================
-- MySQL Subqueries Demonstration
-- Online Store Database Example
-- =============================================
-- Create database and set it as the active database
CREATE DATABASE online_store;
USE online_store;
-- =============================================
-- Create the database
CREATE DATABASE store_inventory;
-- Switch to the new database
USE store_inventory;
-- Create products table
CREATE TABLE products (
product_id INT PRIMARY KEY,
product_name VARCHAR(50) NOT NULL,