SELECT statement

  • SELECT column_name FROM table_name
  • capitalize SQL keywords
  • SELECT c1 FROM table_1
  • SELECT c1,c2 FROM table-1. (request two columns from a table
  • SELECT * FROM table_1
    • this will select all columns from a table
    • it’s mot best practice to use * because it will get everything unless it’s needed, only query certain columns
  • To see what tables you have available to you within database
    • you can go to schemas – tables – see list of tables
  • Challenge Structures – be able to do the following
    • business situation
    • challenge question
    • expected answer
    • hints solution
  • this section is only for practice purposes on this course however – I think in general you will need to think about the business situation and the need so that you can run a good query. I think this is an important point to think of!
  • Situation Example: We want to send out a promotional email to our existing customers!
    • We are going to need information
    • We need to translate this situation into a SQL query
    • we need the customers first and last name and their email addresses
    • use a SELECT statement to grab the first and last names of every customer and their email address