SlideShare a Scribd company logo
1 of 19
CRUD in MySql 
By: Aimal Miakhel
Think of each table as a spreadsheet 
We define columns, also known as fields, 
which classify our data 
Each record in the table is a row
Varchar 
◦ Variable Characters, specify up to how many 
characters something will be 
Char 
◦ A set number of characters, good for things like 
state abbreviations 
Int 
◦ Whole numbers, positive or negative
Float 
◦ Floating Point, also known as a decimal 
Text 
◦ A huge blob of text, like a paragraph or more 
TinyInt / Bit / Boolean 
◦ 0 or 1, True or False 
DateTime 
◦ A date and time 0000-00-00 00:00:00
Depending on the flavor of SQL (Oracle, 
MySQL, MSSQL, PostgreSQL, etc) there are 
many more 
Don’t get overwhelmed, just think of what 
will be best in terms of sorting and lookups
Creating Table in Mysql 
CREATE TABLE User 
( 
ID int, 
Username varchar(255), 
Password varchar(255) 
);
Username 
◦ Varchar 
Password 
◦ Varchar 
ID 
◦ Integer 
AccountCreated 
◦ DateTime
ID UserNa 
me 
Passwo 
rd 
1 John 123 
2 Jane 334 
3 Sally 567 
4 Ryan 8675 
5 Joe 90887 
9 
User _Table
Create 
Read 
Update 
Delete
INSERT is used to create a new record in the 
database 
For example user is a table 
INSERT into user VALUES (1,‘Aimal’, 
‘Miakhel’);
SELECT is used to retrieve a record in the 
database 
To select all the records from user table 
SELECT * FROM user;
Where is used for condition for some specific 
groups or records it filters the selection 
Eg. 
SELECT username, password FROM users 
WHERE ID = 1
UPDATE is used to change record(s) in the 
database 
UPDATE users SET username = ‘Ahmad’ 
WHERE ID = 1 
Or 
UPDATE users SET username = ‘Ahmad’ 
WHERE username = ‘Aimal’
DELETE is used to remove records from the 
database 
DELETE FROM users WHERE ID = 1 
** if you do not specify anything in the WHERE 
clause, it will delete everything in that table
SELECT User FROM Users WHERE ID IN (1,2) 
SELECT * FROM User 
WHERE Name IN (‘Ahmad',‘Ali');
SELECT User FROM Users WHERE ID BETWEEN 
3 AND 5 
SELECT * FROM User 
WHERE ID BETWEEN 3 AND 5;
WHERE can also use wildcards for text 
◦ WHERE Column IS LIKE ‘%something%’ 
WHERE can use more than = 
◦ WHERE ID < 4 
◦ WHERE ID <= 4 
WHERE can combine conditions 
◦ WHERE Column = ‘A’ AND Column2 = ‘B’ 
◦ WHERE Column = ‘A’ OR Column2 = ‘B’ 
◦ WHERE (Column = ‘A’ OR Column2 = B’) AND Other 
= ‘C’
SQL has functions, like COUNT and SUM 
SELECT Customer, SUM(Amount) FROM 
Orders GROUP BY Customer 
SELECT COUNT(Customer) FROM Orders 
GROUP BY Customer
Design a database for university students 
Contains 
Student registration 
Attendance 
Fees 
Etc 
Date-03-09-2014

More Related Content

What's hot

Crud tutorial en
Crud tutorial enCrud tutorial en
Crud tutorial en
forkgrown
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
Varun C M
 

What's hot (20)

SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
PHP - Introduction to Object Oriented Programming with PHP
PHP -  Introduction to  Object Oriented Programming with PHPPHP -  Introduction to  Object Oriented Programming with PHP
PHP - Introduction to Object Oriented Programming with PHP
 
Crud tutorial en
Crud tutorial enCrud tutorial en
Crud tutorial en
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
Arrays in java
Arrays in javaArrays in java
Arrays in java
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Chapter 1 introduction to sql server
Chapter 1 introduction to sql serverChapter 1 introduction to sql server
Chapter 1 introduction to sql server
 
Javascript variables and datatypes
Javascript variables and datatypesJavascript variables and datatypes
Javascript variables and datatypes
 
Css selectors
Css selectorsCss selectors
Css selectors
 
Java script
Java scriptJava script
Java script
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
Dom(document object model)
Dom(document object model)Dom(document object model)
Dom(document object model)
 
Basic SQL and History
 Basic SQL and History Basic SQL and History
Basic SQL and History
 
MYSQL - PHP Database Connectivity
MYSQL - PHP Database ConnectivityMYSQL - PHP Database Connectivity
MYSQL - PHP Database Connectivity
 
Php mysql ppt
Php mysql pptPhp mysql ppt
Php mysql ppt
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
SQL Basics
SQL BasicsSQL Basics
SQL Basics
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 

Viewers also liked

Top 100 PHP Questions and Answers
Top 100 PHP Questions and AnswersTop 100 PHP Questions and Answers
Top 100 PHP Questions and Answers
iimjobs and hirist
 

Viewers also liked (7)

Building RESTtful services in MEAN
Building RESTtful services in MEANBuilding RESTtful services in MEAN
Building RESTtful services in MEAN
 
Top 100 PHP Questions and Answers
Top 100 PHP Questions and AnswersTop 100 PHP Questions and Answers
Top 100 PHP Questions and Answers
 
CodeIgniter 101 Tutorial
CodeIgniter 101 TutorialCodeIgniter 101 Tutorial
CodeIgniter 101 Tutorial
 
Codeigniter
CodeigniterCodeigniter
Codeigniter
 
PHP - Introduction to PHP MySQL Joins and SQL Functions
PHP -  Introduction to PHP MySQL Joins and SQL FunctionsPHP -  Introduction to PHP MySQL Joins and SQL Functions
PHP - Introduction to PHP MySQL Joins and SQL Functions
 
Javascript Best Practices
Javascript Best PracticesJavascript Best Practices
Javascript Best Practices
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JSAdvanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
 

Similar to Mysql Crud, Php Mysql, php, sql

SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
PavithSingh
 
CVJ531: Intro to MySQL
CVJ531: Intro to MySQLCVJ531: Intro to MySQL
CVJ531: Intro to MySQL
Clay Ewing
 
06.01 sql select distinct
06.01 sql select distinct06.01 sql select distinct
06.01 sql select distinct
Bishal Ghimire
 
Database development coding standards
Database development coding standardsDatabase development coding standards
Database development coding standards
Alessandro Baratella
 

Similar to Mysql Crud, Php Mysql, php, sql (20)

Sql
SqlSql
Sql
 
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
Unit-1 SQL fundamentals.docx SQL commands used to create table, insert values...
 
Sql 2006
Sql 2006Sql 2006
Sql 2006
 
Database
Database Database
Database
 
Database Management System 1
Database Management System 1Database Management System 1
Database Management System 1
 
SQL.pptx for the begineers and good know
SQL.pptx for the begineers and good knowSQL.pptx for the begineers and good know
SQL.pptx for the begineers and good know
 
CVJ531: Intro to MySQL
CVJ531: Intro to MySQLCVJ531: Intro to MySQL
CVJ531: Intro to MySQL
 
06.01 sql select distinct
06.01 sql select distinct06.01 sql select distinct
06.01 sql select distinct
 
Database development coding standards
Database development coding standardsDatabase development coding standards
Database development coding standards
 
SQL
SQLSQL
SQL
 
Oracle SQL - Select Part -1 let's write some queries!
Oracle SQL - Select Part -1  let's write some queries!Oracle SQL - Select Part -1  let's write some queries!
Oracle SQL - Select Part -1 let's write some queries!
 
Introduction to database
Introduction to databaseIntroduction to database
Introduction to database
 
SQL
SQLSQL
SQL
 
SQL Lesson 6 - Select.pdf
SQL Lesson 6 - Select.pdfSQL Lesson 6 - Select.pdf
SQL Lesson 6 - Select.pdf
 
Lesson-02 (1).pptx
Lesson-02 (1).pptxLesson-02 (1).pptx
Lesson-02 (1).pptx
 
Oracle notes
Oracle notesOracle notes
Oracle notes
 
STRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGESTRUCTURED QUERY LANGUAGE
STRUCTURED QUERY LANGUAGE
 
Sql
SqlSql
Sql
 
Mysql
MysqlMysql
Mysql
 
Ankit
AnkitAnkit
Ankit
 

Recently uploaded

+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
Health
 

Recently uploaded (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 

Mysql Crud, Php Mysql, php, sql

  • 1. CRUD in MySql By: Aimal Miakhel
  • 2. Think of each table as a spreadsheet We define columns, also known as fields, which classify our data Each record in the table is a row
  • 3. Varchar ◦ Variable Characters, specify up to how many characters something will be Char ◦ A set number of characters, good for things like state abbreviations Int ◦ Whole numbers, positive or negative
  • 4. Float ◦ Floating Point, also known as a decimal Text ◦ A huge blob of text, like a paragraph or more TinyInt / Bit / Boolean ◦ 0 or 1, True or False DateTime ◦ A date and time 0000-00-00 00:00:00
  • 5. Depending on the flavor of SQL (Oracle, MySQL, MSSQL, PostgreSQL, etc) there are many more Don’t get overwhelmed, just think of what will be best in terms of sorting and lookups
  • 6. Creating Table in Mysql CREATE TABLE User ( ID int, Username varchar(255), Password varchar(255) );
  • 7. Username ◦ Varchar Password ◦ Varchar ID ◦ Integer AccountCreated ◦ DateTime
  • 8. ID UserNa me Passwo rd 1 John 123 2 Jane 334 3 Sally 567 4 Ryan 8675 5 Joe 90887 9 User _Table
  • 10. INSERT is used to create a new record in the database For example user is a table INSERT into user VALUES (1,‘Aimal’, ‘Miakhel’);
  • 11. SELECT is used to retrieve a record in the database To select all the records from user table SELECT * FROM user;
  • 12. Where is used for condition for some specific groups or records it filters the selection Eg. SELECT username, password FROM users WHERE ID = 1
  • 13. UPDATE is used to change record(s) in the database UPDATE users SET username = ‘Ahmad’ WHERE ID = 1 Or UPDATE users SET username = ‘Ahmad’ WHERE username = ‘Aimal’
  • 14. DELETE is used to remove records from the database DELETE FROM users WHERE ID = 1 ** if you do not specify anything in the WHERE clause, it will delete everything in that table
  • 15. SELECT User FROM Users WHERE ID IN (1,2) SELECT * FROM User WHERE Name IN (‘Ahmad',‘Ali');
  • 16. SELECT User FROM Users WHERE ID BETWEEN 3 AND 5 SELECT * FROM User WHERE ID BETWEEN 3 AND 5;
  • 17. WHERE can also use wildcards for text ◦ WHERE Column IS LIKE ‘%something%’ WHERE can use more than = ◦ WHERE ID < 4 ◦ WHERE ID <= 4 WHERE can combine conditions ◦ WHERE Column = ‘A’ AND Column2 = ‘B’ ◦ WHERE Column = ‘A’ OR Column2 = ‘B’ ◦ WHERE (Column = ‘A’ OR Column2 = B’) AND Other = ‘C’
  • 18. SQL has functions, like COUNT and SUM SELECT Customer, SUM(Amount) FROM Orders GROUP BY Customer SELECT COUNT(Customer) FROM Orders GROUP BY Customer
  • 19. Design a database for university students Contains Student registration Attendance Fees Etc Date-03-09-2014