Database Access with SQL Relational Databases consist of tables SQL provides command based access to information in a table SQL commands are case-insensitive (case doesn’t matter) Some tables have a Primary key that will auto-increment when new items are added Products Categories in a Grocery Store Products in a Grocery Store More info at: www.w3schools.com/sql
Basic SQL Queries Selecting column information from a table SELECT column1, column2....columnN FROM table_name Selecting column information that meets a condition SELECT column1, column2....columnN FROM table_name WHERE Item1 = Value1 Selecting column information that meets multiple conditions SELECT column1, column2....columnN FROM table_name WHERE Item1 = Value1 {AND|OR} Item2 = Value2
More SQL Queries Select everything matching a condition SELECT * FROM table_name WHERE Item1 = Value1 Select items using a wildcard SELECT * FROM table_name WHERE Title LIKE ‘%match%’ Will match anything containing the string “match”
Modifying the Database Remove (delete) information from a table DELETE FROM table_name WHERE Item1 = Value1 Insert new items (a row) INSERT INTO table_name (Item1, Item2, …) VALUES (Value1, Value2, …) Modify stored data UPDATE table_name SET Item1=Value1, Item2=Value2 WHERE Item3=Value3…