SlideShare a Scribd company logo
CGS 2835 Interdisciplinary Web Development
SQL – The Basics
CGS 2835 Interdisciplinary Web Development
Database Strengths
• Data can be sifted, sorted
and queried through the
use of data manipulation
languages.
 The power of a database and DBMS lies in the user’s
ability to manipulate the data to turn up useful
information.
CGS 2835 Interdisciplinary Web Development
Data Manipulation Language
• A Data Manipulation Language (DML) is a specific
language provided with the DBMS that allows people
and other database users to access, modify, and
make queries about data contained in the database,
and to generate reports.
• Structured Query Language (SQL): The most popular
DML.
– SELECT * FROM EMPLOYEE WHERE JOB_CLASSIFICATION = ‘C2”
CGS 2835 Interdisciplinary Web Development
SQL Commands
SELECT - extracts data from a database
UPDATE - updates data in a database
DELETE - deletes data from a database
INSERT INTO - inserts new data into a database
CREATE DATABASE - creates a new database
ALTER DATABASE - modifies a database
CREATE TABLE - creates a new table
ALTER TABLE - modifies a table
DROP TABLE - deletes a table
CREATE INDEX - creates an index (search key)
DROP INDEX - deletes an index
From www.w3schools.com/sql
CGS 2835 Interdisciplinary Web Development
SELECT
SELECT field_names(s)
FROM table_name
Examples:
SELECT LastName,FirstName FROM Employees
SELECT * FROM Employees
Employee_Id LastName FirstName Address City
1 Baldauf Ola 120 Main St Chicago
2 Svendson Jon 3 Bogus Dr Tallahassee
3 Pettersen Kari 2413 Sayer Ave Tallahassee
4 Willis Carl 12 Bacon Cr Atlanta
5 Smith Jason
LastName FirstName
Baldauf Ola
Svendson Jon
Pettersen Kari
Willis Carl
Smith Jason
Employee_Id LastName FirstName Address City
1 Baldauf Ola 120 Main St Chicago
2 Svendson Jon 3 Bogus Dr Tallahassee
3 Pettersen Kari 2413 Sayer Ave Tallahassee
4 Willis Carl 12 Bacon Cr Atlanta
5 Smith Jason
Employees Table
CGS 2835 Interdisciplinary Web Development
SELECT
SELECT column_name(s)
FROM table_name
WHERE column_name operator value
Example
SELECT * FROM Employees WHERE LastName=’Willis'
Employee_Id LastName FirstName Address City
1 Baldauf Ola 120 Main St Chicago
2 Svendson Jon 3 Bogus Dr Tallahassee
3 Pettersen Kari 2413 Sayer Ave Tallahassee
4 Willis Carl 12 Bacon Cr Atlanta
5 Smith Jason
Employee_Id LastName FirstName Address City
4 Willis Carl 12 Bacon Cr Atlanta
Employees Table
CGS 2835 Interdisciplinary Web Development
SELECT
SELECT column_name(s)
FROM table_name
WHERE column_name operator value
AND/OR column_name operator value
Example
SELECT * FROM Employees WHERE LastName=’Willis’ OR
LastName=‘Pettersen’
Employee_Id LastName FirstName Address City
1 Baldauf Ola 120 Main St Chicago
2 Svendson Jon 3 Bogus Dr Tallahassee
3 Pettersen Kari 2413 Sayer Ave Tallahassee
4 Willis Carl 12 Bacon Cr Atlanta
5 Smith Jason
Employee_Id LastName FirstName Address City
3 Pettersen Kari 2413 Sayer Ave Tallahassee
4 Willis Carl 12 Bacon Cr Atlanta
Employees Table
CGS 2835 Interdisciplinary Web Development
UPDATE
UPDATE table_name
SET column1=value, column2=value2,...
WHERE some_column=some_value
Example
UPDATE Employees
SET Address=’2727 Monroe St', City=’Tallahassee'
WHERE LastName=’Smith' AND FirstName=’Jason'
Employee_Id LastName FirstName Address City
1 Baldauf Ola 120 Main St Chicago
2 Svendson Jon 3 Bogus Dr Tallahassee
3 Pettersen Kari 2413 Sayer Ave Tallahassee
4 Willis Carl 12 Bacon Cr Atlanta
5 Smith Jason
Employees Table
Employee_Id LastName FirstName Address City
1 Baldauf Ola 120 Main St Chicago
2 Svendson Jon 3 Bogus Dr Tallahassee
3 Pettersen Kari 2413 Sayer Ave Tallahassee
4 Willis Carl 12 Bacon Cr Atlanta
5 Smith Jason 2727 Monroe St Tallahassee
CGS 2835 Interdisciplinary Web Development
INSERT INTO
INSERT INTO table_name
(ColumnName1, … , ColumnNameN )
VALUES (‘data1’, … , ‘dataN’)
Example
INSERT INTO Employees (LastName, FirstName, Address, City)
VALUES (‘Larkin’, ‘Robert’, ‘34 W 7th’, ‘Atlanta’)
Employee_Id LastName FirstName Address City
1 Baldauf Ola 120 Main St Chicago
2 Svendson Jon 3 Bogus Dr Tallahassee
3 Pettersen Kari 2413 Sayer Ave Tallahassee
4 Willis Carl 12 Bacon Cr Atlanta
5 Smith Jason
Employees Table
Employee_Id LastName FirstName Address City
1 Baldauf Ola 120 Main St Chicago
2 Svendson Jon 3 Bogus Dr Tallahassee
3 Pettersen Kari 2413 Sayer Ave Tallahassee
4 Willis Carl 12 Bacon Cr Atlanta
5 Smith Jason
6 Larkin Robert 34 W 7th
Atlanta
CGS 2835 Interdisciplinary Web Development
DELETE
DELETE FROM table_name
WHERE some_column=some_value
Example
DELETE FROM Employees
WHERE LastName=’Willis' AND FirstName=’Carl'
Employee_Id LastName FirstName Address City
1 Baldauf Ola 120 Main St Chicago
2 Svendson Jon 3 Bogus Dr Tallahassee
3 Pettersen Kari 2413 Sayer Ave Tallahassee
4 Willis Carl 12 Bacon Cr Atlanta
5 Smith Jason
Employees Table
Employee_Id LastName FirstName Address City
1 Baldauf Ola 120 Main St Chicago
2 Svendson Jon 3 Bogus Dr Tallahassee
3 Pettersen Kari 2413 Sayer Ave Tallahassee
5 Smith Jason 2727 Monroe St Tallahassee
CGS 2835 Interdisciplinary Web Development
PHP > MySQL
CGS 2835 Interdisciplinary Web Development
Accessing a MySQL Database from PHP
First create a database, table, and fields using phpMyAdmin
1.Establish a connection to mySQL server
2.Get the $mysqli database variable
3.Use mysqli_query to issue SQL commands
CGS 2835 Interdisciplinary Web Development
1. Establish a Connection
$mysqli = mysqli_connect($server, $mysql_username , $mysql_password, $database);
$server = "localhost";
$mysql_username = "user";
$mysql_password = "pass";
$database = "test";
CGS 2835 Interdisciplinary Web Development
2. Get the $mysqli database variable
In PHP functions, we will refer to this variable first with:
global $mysqli;
$mysqli = mysqli_connect($server, $mysql_username , $mysql_password, $database);
CGS 2835 Interdisciplinary Web Development
3. Use mysqli_query
to Issue Commands
global $mysqli;
mysqli_query($mysqli, "INSERT INTO visitors
(name, email) VALUES('Timmy Mellowman', 'mellowman@fsu.edu' ) ");
CGS 2835 Interdisciplinary Web Development
3. Use mysqli_query
to Issue Commands
global $mysqli;
$result = mysqli_query($mysqli, "SELECT * FROM visitors”);
while($row = mysql_fetch_array( $result )){
echo ”<p> Name: ".$row['name'] ."<br />";
echo "Email: ".$row['email'] ."<br />";
echo " Date: ".$row['date'] .”</p>";
}
CGS 2835 Interdisciplinary Web Development
Useful Resources
• Tizag PHP/MySQL Tutorial
– http://www.tizag.com/mysqlTutorial
• W3Schools
– PHP MySQL: http://www.w3schools.com/php/php_mysql_intro.asp
– SQL: http://www.w3schools.com/sql/default.asp
• MySQL Manual:
– http://dev.mysql.com/doc/refman/5.0/en
• PHP MySQL functions:
– http://www.php.net/manual/en/book.mysqli.php

More Related Content

What's hot

NOSQL vs SQL
NOSQL vs SQLNOSQL vs SQL
NOSQL vs SQL
Mohammed Fazuluddin
 
Database and types of database
Database and types of databaseDatabase and types of database
Database and types of database
baabtra.com - No. 1 supplier of quality freshers
 
Knonex
KnonexKnonex
My sql vs mongo
My sql vs mongoMy sql vs mongo
My sql vs mongo
krishnapriya Tadepalli
 
SQL vs. NoSQL Databases
SQL vs. NoSQL DatabasesSQL vs. NoSQL Databases
SQL vs. NoSQL Databases
Osama Jomaa
 
Advanced SQL Server Performance Tuning | IDERA
Advanced SQL Server Performance Tuning | IDERAAdvanced SQL Server Performance Tuning | IDERA
Advanced SQL Server Performance Tuning | IDERA
IDERA Software
 
NoSQL for SQL Users
NoSQL for SQL UsersNoSQL for SQL Users
NoSQL for SQL Users
IBM Cloud Data Services
 
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | EdurekaSQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
Edureka!
 
SQL Server 2019 Data Virtualization
SQL Server 2019 Data VirtualizationSQL Server 2019 Data Virtualization
SQL Server 2019 Data Virtualization
Matthew W. Bowers
 
Introduction to mongodb
Introduction to mongodbIntroduction to mongodb
Introduction to mongodb
neela madheswari
 
Multi-model databases and node.js
Multi-model databases and node.jsMulti-model databases and node.js
Multi-model databases and node.js
Max Neunhöffer
 
Practical Use of a NoSQL
Practical Use of a NoSQLPractical Use of a NoSQL
Practical Use of a NoSQL
IBM Cloud Data Services
 
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERA
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERABe Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERA
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERA
IDERA Software
 
Build 2017 - P4010 - A lap around Azure HDInsight and Cosmos DB Open Source A...
Build 2017 - P4010 - A lap around Azure HDInsight and Cosmos DB Open Source A...Build 2017 - P4010 - A lap around Azure HDInsight and Cosmos DB Open Source A...
Build 2017 - P4010 - A lap around Azure HDInsight and Cosmos DB Open Source A...
Windows Developer
 
Introduction to mongoDB
Introduction to mongoDBIntroduction to mongoDB
Introduction to mongoDB
Cuelogic Technologies Pvt. Ltd.
 
Sql vs. NoSql
Sql vs. NoSqlSql vs. NoSql
Sql vs. NoSql
Chuong Mai
 
Azure document db/Cosmos DB
Azure document db/Cosmos DBAzure document db/Cosmos DB
Azure document db/Cosmos DB
Mohit Chhabra
 
MongoDB by Emroz sardar.
MongoDB by Emroz sardar.MongoDB by Emroz sardar.
MongoDB by Emroz sardar.
Emroz Sardar
 
NoSQL
NoSQLNoSQL
SQL vs NoSQL: Big Data Adoption & Success in the Enterprise
SQL vs NoSQL: Big Data Adoption & Success in the EnterpriseSQL vs NoSQL: Big Data Adoption & Success in the Enterprise
SQL vs NoSQL: Big Data Adoption & Success in the Enterprise
Anita Luthra
 

What's hot (20)

NOSQL vs SQL
NOSQL vs SQLNOSQL vs SQL
NOSQL vs SQL
 
Database and types of database
Database and types of databaseDatabase and types of database
Database and types of database
 
Knonex
KnonexKnonex
Knonex
 
My sql vs mongo
My sql vs mongoMy sql vs mongo
My sql vs mongo
 
SQL vs. NoSQL Databases
SQL vs. NoSQL DatabasesSQL vs. NoSQL Databases
SQL vs. NoSQL Databases
 
Advanced SQL Server Performance Tuning | IDERA
Advanced SQL Server Performance Tuning | IDERAAdvanced SQL Server Performance Tuning | IDERA
Advanced SQL Server Performance Tuning | IDERA
 
NoSQL for SQL Users
NoSQL for SQL UsersNoSQL for SQL Users
NoSQL for SQL Users
 
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | EdurekaSQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
SQL vs NoSQL | MySQL vs MongoDB Tutorial | Edureka
 
SQL Server 2019 Data Virtualization
SQL Server 2019 Data VirtualizationSQL Server 2019 Data Virtualization
SQL Server 2019 Data Virtualization
 
Introduction to mongodb
Introduction to mongodbIntroduction to mongodb
Introduction to mongodb
 
Multi-model databases and node.js
Multi-model databases and node.jsMulti-model databases and node.js
Multi-model databases and node.js
 
Practical Use of a NoSQL
Practical Use of a NoSQLPractical Use of a NoSQL
Practical Use of a NoSQL
 
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERA
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERABe Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERA
Be Proactive: A Good DBA Goes Looking for Signs of Trouble | IDERA
 
Build 2017 - P4010 - A lap around Azure HDInsight and Cosmos DB Open Source A...
Build 2017 - P4010 - A lap around Azure HDInsight and Cosmos DB Open Source A...Build 2017 - P4010 - A lap around Azure HDInsight and Cosmos DB Open Source A...
Build 2017 - P4010 - A lap around Azure HDInsight and Cosmos DB Open Source A...
 
Introduction to mongoDB
Introduction to mongoDBIntroduction to mongoDB
Introduction to mongoDB
 
Sql vs. NoSql
Sql vs. NoSqlSql vs. NoSql
Sql vs. NoSql
 
Azure document db/Cosmos DB
Azure document db/Cosmos DBAzure document db/Cosmos DB
Azure document db/Cosmos DB
 
MongoDB by Emroz sardar.
MongoDB by Emroz sardar.MongoDB by Emroz sardar.
MongoDB by Emroz sardar.
 
NoSQL
NoSQLNoSQL
NoSQL
 
SQL vs NoSQL: Big Data Adoption & Success in the Enterprise
SQL vs NoSQL: Big Data Adoption & Success in the EnterpriseSQL vs NoSQL: Big Data Adoption & Success in the Enterprise
SQL vs NoSQL: Big Data Adoption & Success in the Enterprise
 

Similar to Phpmysqlcoding

Sql Server 2000
Sql Server 2000Sql Server 2000
Sql Server 2000
Om Vikram Thapa
 
Database
DatabaseDatabase
LECTURE NOTES.pdf
LECTURE NOTES.pdfLECTURE NOTES.pdf
LECTURE NOTES.pdf
ChryslerPanaguiton
 
LECTURE NOTES.pdf
LECTURE NOTES.pdfLECTURE NOTES.pdf
LECTURE NOTES.pdf
ChryslerPanaguiton
 
Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL
Abdul Rehman
 
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdfDBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
AbhishekKumarPandit5
 
Data base.ppt
Data base.pptData base.ppt
Data base.ppt
TeklayBirhane
 
CC105-WEEK10-11-INTRODUCTION-TO-SQL.pdf
CC105-WEEK10-11-INTRODUCTION-TO-SQL.pdfCC105-WEEK10-11-INTRODUCTION-TO-SQL.pdf
CC105-WEEK10-11-INTRODUCTION-TO-SQL.pdf
ozaixyzo
 
SQL
SQLSQL
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
webhostingguy
 
Sql
SqlSql
Introduction to database & sql
Introduction to database & sqlIntroduction to database & sql
Introduction to database & sql
zahid6
 
Module 3
Module 3Module 3
Module 3
cs19club
 
My sql
My sqlMy sql
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
Nishant Munjal
 
Databases and SQL - Lecture C
Databases and SQL - Lecture CDatabases and SQL - Lecture C
Databases and SQL - Lecture C
CMDLearning
 
SQL Server 2000 Research Series - Performance Tuning
SQL Server 2000 Research Series - Performance TuningSQL Server 2000 Research Series - Performance Tuning
SQL Server 2000 Research Series - Performance Tuning
Jerry Yang
 
SQL basics.pptx
SQL basics.pptxSQL basics.pptx
SQL basics.pptx
ZakReeceJames
 
Intro to Database Design
Intro to Database DesignIntro to Database Design
Intro to Database Design
Sondra Willhite
 
data manipulation language
data manipulation languagedata manipulation language
data manipulation language
JananiSelvaraj10
 

Similar to Phpmysqlcoding (20)

Sql Server 2000
Sql Server 2000Sql Server 2000
Sql Server 2000
 
Database
DatabaseDatabase
Database
 
LECTURE NOTES.pdf
LECTURE NOTES.pdfLECTURE NOTES.pdf
LECTURE NOTES.pdf
 
LECTURE NOTES.pdf
LECTURE NOTES.pdfLECTURE NOTES.pdf
LECTURE NOTES.pdf
 
Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL Oracle Database DML DDL and TCL
Oracle Database DML DDL and TCL
 
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdfDBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
DBMS LAB FILE1 task 1 , task 2, task3 and many more.pdf
 
Data base.ppt
Data base.pptData base.ppt
Data base.ppt
 
CC105-WEEK10-11-INTRODUCTION-TO-SQL.pdf
CC105-WEEK10-11-INTRODUCTION-TO-SQL.pdfCC105-WEEK10-11-INTRODUCTION-TO-SQL.pdf
CC105-WEEK10-11-INTRODUCTION-TO-SQL.pdf
 
SQL
SQLSQL
SQL
 
MYSQL.ppt
MYSQL.pptMYSQL.ppt
MYSQL.ppt
 
Sql
SqlSql
Sql
 
Introduction to database & sql
Introduction to database & sqlIntroduction to database & sql
Introduction to database & sql
 
Module 3
Module 3Module 3
Module 3
 
My sql
My sqlMy sql
My sql
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
 
Databases and SQL - Lecture C
Databases and SQL - Lecture CDatabases and SQL - Lecture C
Databases and SQL - Lecture C
 
SQL Server 2000 Research Series - Performance Tuning
SQL Server 2000 Research Series - Performance TuningSQL Server 2000 Research Series - Performance Tuning
SQL Server 2000 Research Series - Performance Tuning
 
SQL basics.pptx
SQL basics.pptxSQL basics.pptx
SQL basics.pptx
 
Intro to Database Design
Intro to Database DesignIntro to Database Design
Intro to Database Design
 
data manipulation language
data manipulation languagedata manipulation language
data manipulation language
 

More from Program in Interdisciplinary Computing

CGS2835 HTML5
CGS2835 HTML5CGS2835 HTML5
Mysocial databasequeries
Mysocial databasequeriesMysocial databasequeries
Mysocial databasequeries
Program in Interdisciplinary Computing
 
Mysocial databasequeries
Mysocial databasequeriesMysocial databasequeries
Mysocial databasequeries
Program in Interdisciplinary Computing
 
CGS2835 HTML5
CGS2835 HTML5CGS2835 HTML5
01 intro tousingjava
01 intro tousingjava01 intro tousingjava
Xhtml
XhtmlXhtml
Web architecture
Web architectureWeb architecture
Sdlc
SdlcSdlc
Mysocial
MysocialMysocial
Javascript
JavascriptJavascript
Javascript
JavascriptJavascript
Html5
Html5Html5
Frameworks
FrameworksFrameworks
Drupal
DrupalDrupal
Javascript2
Javascript2Javascript2
12 abstract classes
12 abstract classes12 abstract classes
11 polymorphism
11 polymorphism11 polymorphism
13 interfaces
13 interfaces13 interfaces
15b more gui
15b more gui15b more gui

More from Program in Interdisciplinary Computing (20)

CGS2835 HTML5
CGS2835 HTML5CGS2835 HTML5
CGS2835 HTML5
 
Mysocial databasequeries
Mysocial databasequeriesMysocial databasequeries
Mysocial databasequeries
 
Mysocial databasequeries
Mysocial databasequeriesMysocial databasequeries
Mysocial databasequeries
 
CGS2835 HTML5
CGS2835 HTML5CGS2835 HTML5
CGS2835 HTML5
 
01 intro tousingjava
01 intro tousingjava01 intro tousingjava
01 intro tousingjava
 
Xhtml
XhtmlXhtml
Xhtml
 
Webdev
WebdevWebdev
Webdev
 
Web architecture
Web architectureWeb architecture
Web architecture
 
Sdlc
SdlcSdlc
Sdlc
 
Mysocial
MysocialMysocial
Mysocial
 
Javascript
JavascriptJavascript
Javascript
 
Javascript
JavascriptJavascript
Javascript
 
Html5
Html5Html5
Html5
 
Frameworks
FrameworksFrameworks
Frameworks
 
Drupal
DrupalDrupal
Drupal
 
Javascript2
Javascript2Javascript2
Javascript2
 
12 abstract classes
12 abstract classes12 abstract classes
12 abstract classes
 
11 polymorphism
11 polymorphism11 polymorphism
11 polymorphism
 
13 interfaces
13 interfaces13 interfaces
13 interfaces
 
15b more gui
15b more gui15b more gui
15b more gui
 

Recently uploaded

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
DianaGray10
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
Kari Kakkonen
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
Aftab Hussain
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
Adtran
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
Quotidiano Piemontese
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
Uni Systems S.M.S.A.
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
Zilliz
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
Octavian Nadolu
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
KAMESHS29
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
Safe Software
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
sonjaschweigert1
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
Neo4j
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
James Anderson
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
Neo4j
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
Kumud Singh
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
Rohit Gautam
 

Recently uploaded (20)

UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5UiPath Test Automation using UiPath Test Suite series, part 5
UiPath Test Automation using UiPath Test Suite series, part 5
 
Climate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing DaysClimate Impact of Software Testing at Nordic Testing Days
Climate Impact of Software Testing at Nordic Testing Days
 
Removing Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software FuzzingRemoving Uninteresting Bytes in Software Fuzzing
Removing Uninteresting Bytes in Software Fuzzing
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Pushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 daysPushing the limits of ePRTC: 100ns holdover for 100 days
Pushing the limits of ePRTC: 100ns holdover for 100 days
 
National Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practicesNational Security Agency - NSA mobile device best practices
National Security Agency - NSA mobile device best practices
 
Microsoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdfMicrosoft - Power Platform_G.Aspiotis.pdf
Microsoft - Power Platform_G.Aspiotis.pdf
 
Full-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalizationFull-RAG: A modern architecture for hyper-personalization
Full-RAG: A modern architecture for hyper-personalization
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Artificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopmentArtificial Intelligence for XMLDevelopment
Artificial Intelligence for XMLDevelopment
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
RESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for studentsRESUME BUILDER APPLICATION Project for students
RESUME BUILDER APPLICATION Project for students
 
Essentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FMEEssentials of Automations: The Art of Triggers and Actions in FME
Essentials of Automations: The Art of Triggers and Actions in FME
 
A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...A tale of scale & speed: How the US Navy is enabling software delivery from l...
A tale of scale & speed: How the US Navy is enabling software delivery from l...
 
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
GraphSummit Singapore | Graphing Success: Revolutionising Organisational Stru...
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
 
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
GraphSummit Singapore | Neo4j Product Vision & Roadmap - Q2 2024
 
Mind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AIMind map of terminologies used in context of Generative AI
Mind map of terminologies used in context of Generative AI
 
Large Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial ApplicationsLarge Language Model (LLM) and it’s Geospatial Applications
Large Language Model (LLM) and it’s Geospatial Applications
 

Phpmysqlcoding

  • 1. CGS 2835 Interdisciplinary Web Development SQL – The Basics
  • 2. CGS 2835 Interdisciplinary Web Development Database Strengths • Data can be sifted, sorted and queried through the use of data manipulation languages.  The power of a database and DBMS lies in the user’s ability to manipulate the data to turn up useful information.
  • 3. CGS 2835 Interdisciplinary Web Development Data Manipulation Language • A Data Manipulation Language (DML) is a specific language provided with the DBMS that allows people and other database users to access, modify, and make queries about data contained in the database, and to generate reports. • Structured Query Language (SQL): The most popular DML. – SELECT * FROM EMPLOYEE WHERE JOB_CLASSIFICATION = ‘C2”
  • 4. CGS 2835 Interdisciplinary Web Development SQL Commands SELECT - extracts data from a database UPDATE - updates data in a database DELETE - deletes data from a database INSERT INTO - inserts new data into a database CREATE DATABASE - creates a new database ALTER DATABASE - modifies a database CREATE TABLE - creates a new table ALTER TABLE - modifies a table DROP TABLE - deletes a table CREATE INDEX - creates an index (search key) DROP INDEX - deletes an index From www.w3schools.com/sql
  • 5. CGS 2835 Interdisciplinary Web Development SELECT SELECT field_names(s) FROM table_name Examples: SELECT LastName,FirstName FROM Employees SELECT * FROM Employees Employee_Id LastName FirstName Address City 1 Baldauf Ola 120 Main St Chicago 2 Svendson Jon 3 Bogus Dr Tallahassee 3 Pettersen Kari 2413 Sayer Ave Tallahassee 4 Willis Carl 12 Bacon Cr Atlanta 5 Smith Jason LastName FirstName Baldauf Ola Svendson Jon Pettersen Kari Willis Carl Smith Jason Employee_Id LastName FirstName Address City 1 Baldauf Ola 120 Main St Chicago 2 Svendson Jon 3 Bogus Dr Tallahassee 3 Pettersen Kari 2413 Sayer Ave Tallahassee 4 Willis Carl 12 Bacon Cr Atlanta 5 Smith Jason Employees Table
  • 6. CGS 2835 Interdisciplinary Web Development SELECT SELECT column_name(s) FROM table_name WHERE column_name operator value Example SELECT * FROM Employees WHERE LastName=’Willis' Employee_Id LastName FirstName Address City 1 Baldauf Ola 120 Main St Chicago 2 Svendson Jon 3 Bogus Dr Tallahassee 3 Pettersen Kari 2413 Sayer Ave Tallahassee 4 Willis Carl 12 Bacon Cr Atlanta 5 Smith Jason Employee_Id LastName FirstName Address City 4 Willis Carl 12 Bacon Cr Atlanta Employees Table
  • 7. CGS 2835 Interdisciplinary Web Development SELECT SELECT column_name(s) FROM table_name WHERE column_name operator value AND/OR column_name operator value Example SELECT * FROM Employees WHERE LastName=’Willis’ OR LastName=‘Pettersen’ Employee_Id LastName FirstName Address City 1 Baldauf Ola 120 Main St Chicago 2 Svendson Jon 3 Bogus Dr Tallahassee 3 Pettersen Kari 2413 Sayer Ave Tallahassee 4 Willis Carl 12 Bacon Cr Atlanta 5 Smith Jason Employee_Id LastName FirstName Address City 3 Pettersen Kari 2413 Sayer Ave Tallahassee 4 Willis Carl 12 Bacon Cr Atlanta Employees Table
  • 8. CGS 2835 Interdisciplinary Web Development UPDATE UPDATE table_name SET column1=value, column2=value2,... WHERE some_column=some_value Example UPDATE Employees SET Address=’2727 Monroe St', City=’Tallahassee' WHERE LastName=’Smith' AND FirstName=’Jason' Employee_Id LastName FirstName Address City 1 Baldauf Ola 120 Main St Chicago 2 Svendson Jon 3 Bogus Dr Tallahassee 3 Pettersen Kari 2413 Sayer Ave Tallahassee 4 Willis Carl 12 Bacon Cr Atlanta 5 Smith Jason Employees Table Employee_Id LastName FirstName Address City 1 Baldauf Ola 120 Main St Chicago 2 Svendson Jon 3 Bogus Dr Tallahassee 3 Pettersen Kari 2413 Sayer Ave Tallahassee 4 Willis Carl 12 Bacon Cr Atlanta 5 Smith Jason 2727 Monroe St Tallahassee
  • 9. CGS 2835 Interdisciplinary Web Development INSERT INTO INSERT INTO table_name (ColumnName1, … , ColumnNameN ) VALUES (‘data1’, … , ‘dataN’) Example INSERT INTO Employees (LastName, FirstName, Address, City) VALUES (‘Larkin’, ‘Robert’, ‘34 W 7th’, ‘Atlanta’) Employee_Id LastName FirstName Address City 1 Baldauf Ola 120 Main St Chicago 2 Svendson Jon 3 Bogus Dr Tallahassee 3 Pettersen Kari 2413 Sayer Ave Tallahassee 4 Willis Carl 12 Bacon Cr Atlanta 5 Smith Jason Employees Table Employee_Id LastName FirstName Address City 1 Baldauf Ola 120 Main St Chicago 2 Svendson Jon 3 Bogus Dr Tallahassee 3 Pettersen Kari 2413 Sayer Ave Tallahassee 4 Willis Carl 12 Bacon Cr Atlanta 5 Smith Jason 6 Larkin Robert 34 W 7th Atlanta
  • 10. CGS 2835 Interdisciplinary Web Development DELETE DELETE FROM table_name WHERE some_column=some_value Example DELETE FROM Employees WHERE LastName=’Willis' AND FirstName=’Carl' Employee_Id LastName FirstName Address City 1 Baldauf Ola 120 Main St Chicago 2 Svendson Jon 3 Bogus Dr Tallahassee 3 Pettersen Kari 2413 Sayer Ave Tallahassee 4 Willis Carl 12 Bacon Cr Atlanta 5 Smith Jason Employees Table Employee_Id LastName FirstName Address City 1 Baldauf Ola 120 Main St Chicago 2 Svendson Jon 3 Bogus Dr Tallahassee 3 Pettersen Kari 2413 Sayer Ave Tallahassee 5 Smith Jason 2727 Monroe St Tallahassee
  • 11. CGS 2835 Interdisciplinary Web Development PHP > MySQL
  • 12. CGS 2835 Interdisciplinary Web Development Accessing a MySQL Database from PHP First create a database, table, and fields using phpMyAdmin 1.Establish a connection to mySQL server 2.Get the $mysqli database variable 3.Use mysqli_query to issue SQL commands
  • 13. CGS 2835 Interdisciplinary Web Development 1. Establish a Connection $mysqli = mysqli_connect($server, $mysql_username , $mysql_password, $database); $server = "localhost"; $mysql_username = "user"; $mysql_password = "pass"; $database = "test";
  • 14. CGS 2835 Interdisciplinary Web Development 2. Get the $mysqli database variable In PHP functions, we will refer to this variable first with: global $mysqli; $mysqli = mysqli_connect($server, $mysql_username , $mysql_password, $database);
  • 15. CGS 2835 Interdisciplinary Web Development 3. Use mysqli_query to Issue Commands global $mysqli; mysqli_query($mysqli, "INSERT INTO visitors (name, email) VALUES('Timmy Mellowman', 'mellowman@fsu.edu' ) ");
  • 16. CGS 2835 Interdisciplinary Web Development 3. Use mysqli_query to Issue Commands global $mysqli; $result = mysqli_query($mysqli, "SELECT * FROM visitors”); while($row = mysql_fetch_array( $result )){ echo ”<p> Name: ".$row['name'] ."<br />"; echo "Email: ".$row['email'] ."<br />"; echo " Date: ".$row['date'] .”</p>"; }
  • 17. CGS 2835 Interdisciplinary Web Development Useful Resources • Tizag PHP/MySQL Tutorial – http://www.tizag.com/mysqlTutorial • W3Schools – PHP MySQL: http://www.w3schools.com/php/php_mysql_intro.asp – SQL: http://www.w3schools.com/sql/default.asp • MySQL Manual: – http://dev.mysql.com/doc/refman/5.0/en • PHP MySQL functions: – http://www.php.net/manual/en/book.mysqli.php