SlideShare une entreprise Scribd logo
1  sur  17
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

Contenu connexe

Tendances

SQL vs. NoSQL Databases
SQL vs. NoSQL DatabasesSQL vs. NoSQL Databases
SQL vs. NoSQL DatabasesOsama Jomaa
 
Advanced SQL Server Performance Tuning | IDERA
Advanced SQL Server Performance Tuning | IDERAAdvanced SQL Server Performance Tuning | IDERA
Advanced SQL Server Performance Tuning | IDERAIDERA Software
 
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 | EdurekaEdureka!
 
SQL Server 2019 Data Virtualization
SQL Server 2019 Data VirtualizationSQL Server 2019 Data Virtualization
SQL Server 2019 Data VirtualizationMatthew W. Bowers
 
Multi-model databases and node.js
Multi-model databases and node.jsMulti-model databases and node.js
Multi-model databases and node.jsMax Neunhöffer
 
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 | IDERAIDERA 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
 
Azure document db/Cosmos DB
Azure document db/Cosmos DBAzure document db/Cosmos DB
Azure document db/Cosmos DBMohit Chhabra
 
MongoDB by Emroz sardar.
MongoDB by Emroz sardar.MongoDB by Emroz sardar.
MongoDB by Emroz sardar.Emroz Sardar
 
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 EnterpriseAnita Luthra
 

Tendances (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
 

Similaire à Phpmysqlcoding

Similaire à 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
 

Plus de 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
 

Dernier

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 

Dernier (20)

A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 

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