SQL Basics
- Structured Query Language
- With some variations, SQL is more or less the standard query language for relational databases
- Table = is a “tab” (in excel) for a set of data
- SQL is a relational database
- I have to have some connection between the tables
- SQL Has four major components
- DQL (Data Query Language) Used to retrieve data from a database
- DML (Data Manipulation language) Used to modify the data in a database inserting updating and deleting
- DDL (Data Definition language) Used to design tables and other database objects
- DCL (Data Control Language) Used to control access to the data using security methods.
- Four Basic Operations
- CRUD
- C - Create
- R - Read
- U - Update
- D - Delete
- CRUD
-
- is a wildcard this can mean anything
- Select
- SELECT state_name, state_abbr FROM states
- Where Clause
- Boolean logic
- SELECT state_name FROM states WHERE state_population > 150,000
- AND - All conditions True
PHP And MySQL Integration and SQL Injection
- mysqli() is a class of function that allows PHP to interact with the database
- To open connection
- new mysqli(server,user_name,passwd,database);
- mysqli→query(SELECT * from customers where zip=05401)
- Mysqli →query(query syntax) is function to send query