1. Some Basic Terminologies
    1. DBMS
      1. Data Base Management System -> is used to control the Data Base.
    2. Data Base
      1. It's an electronic way to hold (store) information/data basically they are classified into relational and non relational. Relational vs Non Relational DBs Relational DBs are organized in tables and there is some sort of relation between a table and another (MySQL, MSSQL, Oracle, ..) Non Relational DB : also referred to as NoSQL DBs are not organized in tables like
    3. Tables
      1. A unit made up of some columns as headers and rows to store actual data
    4. SQL
      1. Structured Query Language is a language used for querying databases
  2. DDL Commands -> Data Definition Language
    1. CREATE
      1. DATABASE
        1. CREATE DATABASE DBName ;
      2. TABLE
        1. CREATE TABLE TABLEName ( column1 datatype [options], column2 datatype [options], column3 datatype [options], ...... ) ;
    2. DROP
      1. DATABASE
        1. DROP DATABASE DBName ;
      2. TABLE
        1. DROP TABLE TABLEName ;
    3. ALTER
      1. DATABASE PROPERTY
      2. TABLE
  3. DML Commands -> Data Manipulation Language
    1. Insert
      1. INSERT INTO TABLEName (`col1` , `col2`) VALUES ( `value1`, `value2` ); or you can use this way to INSERT INTO TABLEName SET `col1` = `value1` , `col2` = `value2` ;
    2. Update
      1. UPDATE TABLEName SET `col1` = `value1` , `col2` = `value2` WHERE `col` = `value`;
    3. Delete
      1. DELETE FROM TABLEName WHERE `col` = `value`;
      2. DELETE FROM TABLEName WHERE col BETWEEN value1 AND value2
    4. Select
      1. SELECT [*/username/or any column in your table] FROM TABLEName ;-> to get listing of all columns and its values in a table
      2. SELECT * FROM TABLENAME ORDER BY username/id/password ; or any other column -> to get listing of all columns and its values in a table ordered by ...
      3. SELECT count(*) FROM TABLEName ;
  4. Conditions
    1. IF(condition, value_if_true, value_if_false) Ex: select if(1=1, sleep(3), null); here the condition is true so it will trigger a delay for 3 seconds Ex: select name from content where id=128 and if(substr((select table_name from information_schema.tables where table_schema=database()),1,1)='a',true,false); Ex: select if((select concat_ws(name,id,image,score) from content where name='user1'),true,false); select * from content where id=128 and (if((length((select name from content where id=148))=7),true,false));
    2. When conditions case when (your condition here) then some result for true else some result for false end ; Ex: select * from content where id=128 and (select case when (length((select name from content where id=148))=7) then true else false end) ; select * from content where id=128 and case when (length((select name from content where id=148))=7) then true else false end; -> with out the additional select statement
  5. Some useful SQL keywords/clauses/operators
    1. this operator is used to combine the result of two select statements or more basic syntax -> select COLUMN from TABLEName where id=somevalue union select ANOTHER_COLUMN from TABLEName where something ...
    2. the where command is used to filter queried data by matching some condition you give after the where keyword ex: select * from TABLEName where username="blablabla"
    3. the LIKE clause helps you to search the table with input the is not and exact match it's all about placing the wildcard % ex : select * from TABLEName where name like "%6" ; select * from TABLEName where name like "%ser%" ;
    4. The ORDER BY command is used to sort the result set in ascending or descending order Ascending by default ex: select username from users order by id
    5. the LIMIT clause can be used to select the number of rows to be returned from your query and also select the starting row (or how many rows to skip before returning the output)
    6. UNION
    7. WHERE
    8. ORDER BY
    9. LIMIT
    10. LIKE
  6. CRUD operations using PHP and MySQL
    1. Create
    2. List/Read
    3. Update
    4. Delete
  7. PHP and connecting to DB
    1. Method 1
    2. Method 2
  8. Column Data Types
  9. RESET YOUR COUNTER FOR EXAMPLE YOUR ID COUNTER TO COUNT FROM 1 AGAIN IF IT CHANGED DURING ANY MODIFICATION SET @NUM := 0; UPDATE YOUR_TABLE SET ID = @NUM := (@NUM+1); ALTER TABLE YOUR_TABLE AUTO_INCREMENT =1;
  10. IF Conditions
  11. When Condtions