Académique Documents
Professionnel Documents
Culture Documents
via the PHP MySQL , Select, where, order by Database Design Concepts
MySQL is a relational database management system (RDBMS) that runs as a server providing multi-user access to a number of databases. It is named after developer Michael Widenius daughter, My. The SQL phrase stands for Structured Query Language. MySQL is the most popular Open Source Relational SQL database management system. MySQL is one of the best RDBMS being used for developing web based software applications.
SQL
SQL is a standard language for accessing and manipulating databases What Can SQL do? SQL can retrieve data from a database SQL can insert records in a database SQL can update records in a database SQL can delete records from a database SQL can create new databases SQL can create new tables in a database SQL can create stored procedures in a database SQL can create views in a database SQL can set permissions on tables, procedures, and views SQL - often referred to as Structured Query Language) is a programming language designed for managing data in relational database management systems (RDBMS). Originally based upon relational algebra and tuple relational calculus, its scope includes data insert, query, update and delete, schema creation and modification, and data access control. SQL was one of the first commercial languages for Edgar F. Codd's relational model, as described in his influential 1970 paper, "A Relational Model of Data for Large Shared Data Banks".Despite not adhering to the relational model as described by Codd, it became the most widely used database language.
SQL Statements Most of the actions you need to perform on a database are done with SQL statements. SQL can be divided into two parts: The Data Manipulation Language (DML)
The query and update commands form the DML part of SQL:
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
The DDL part of SQL permits database tables to be created or deleted. The most important DDL statements in SQL are: CREATE DATABASE ALTER DATABASE CREATE TABLE ALTER TABLE DROP TABLE CREATE INDEX DROP INDEX - creates a new database - modifies a database - creates a new table - modifies a table - deletes a table - creates an index (search key) - deletes an index
If you were thinking of what was the difference between MySQL and SQL. Now here is the answer.
databases;
MySQL
is
database
SQL is a common database computer language designed for the retrieval and management of data in relational database management systems (RDBMS) -basically a standard interactive and programming language for querying and modifying data and managing databases. Very standard for uses ranging from the simplest Microsoft Access applications, up to complex multiserver distributed Oracle applications. MySQL is a multithreaded, multi-user SQL database management system (DBMS) providing multi-user access to a number of databases. MySQL is commonly
the back engine database for a great many applications, and often the database of choice for web-based applications.
SQL Statements
Most of the actions you need to perform on a database are done with SQL statements. Entering in Command Prompt Syntax:
cd\ cd xampp\mysql\bin mysql u root after typing the syntax there will be a Welcome to MySQL monitor..notification as seen at left.
SQL syntax
Creating a database Syntax create database database_name; Using the database Syntax use database_name; use csc130; My sample create database csc130;
Order by Syntax
select * from table_name order by name ; select * from student order by name ;
The output is displaying the student information starting the name from A-Z.
Adding Field
Alter table table_name add field_name value ; Alter table student add email value char(30);
The student information add other attribute the email. Now the attribute are idno, fullname, course, email.
Before you can connect to the database, you need four things: Database name Host Server name Username Password Connect to the database using the following command (in PHP): $connection = mysql_connect(servername, username, password);
You then need to select the appropriate database by using the following command (in PHP): <?php $database = mysql_select_db(databasename, $connection) or die(couldnt find the database); ?>
Note: I refer this to what Ive created above, the student is the table_name and s_id is only a variable I address to student idno, s_fname is the student fullname and so on.