Back to 课程

Computer Science GCES OCR

0% Complete
0/0 Steps
  1. Cpu Architecture Performance And Embedded Systems Ocr
    5 主题
  2. Primary And Secondary Storage Ocr
    6 主题
  3. Data Storage And Compression Ocr
    12 主题
  4. Networks And Topologies Ocr
    6 主题
  5. Wired And Wireless Networks Protocols And Layers Ocr
    6 主题
  6. Identifying And Preventing Threats To Computer Systems And Networks Ocr
    2 主题
  7. Operating Systems And Utility Software Ocr
    2 主题
  8. Ethical Legal Cultural And Environmental Impact Ocr
    2 主题
  9. Computational Thinking Searching And Sorting Algorithms Ocr
    3 主题
  10. Designing Creating And Refining Algorithms Ocr
    5 主题
  11. Programming Fundamentals And Data Types Ocr
    5 主题
  12. Additional Programming Techniques Ocr
    7 主题
  13. Defensive Design And Testing Ocr
    6 主题
  14. Boolean Logic Diagrams Ocr
    2 主题
  15. Programming Languages And Integrated Development Environments Ides Ocr
    3 主题
  16. The Exam Papers Ocr
    2 主题
  17. Structuring Your Responses Ocr
    3 主题
课 Progress
0% Complete

Exam code:J277

SQL

What is SQL?

  • SQL (Structured Query Language) is a programming language used to interact with a DBMS.

  • SQL allows users to locate specific information in a database table using these basic SQL commands:

    • Select – what field(s) do you want to retrieve?

    • From – which table(s) do you want to search?

    • Where – what condition is there?

Selecting Data Commands

Command

Description

Example

SELECT

Retrieves data from a database table

SELECT *
(retrieves all data from the table)

SELECT name, age
(retrieves names and ages from the table)

FROM

Specifies the tables to retrieve data from

SELECT *
FROM users;
(retrieves all data from the ‘users’ table)

SELECT name, age
FROM users;
(retrieves names and ages from the ‘users’ table)

WHERE

Filters the data based on a specified condition

SELECT *
FROM users
WHERE age > 30;
(Retrieves all users older than 30)

  • The ‘*‘ symbol is called a ‘wildcard‘, it selects all fields in the table

Examples

  • Select all the fields from the Customers table

Command:

SQL query snippet: "SELECT * FROM Customers;" in a code editor highlighting "SELECT" in purple and "FROM" in pink, both on a black background.

Output:

ID

Name

Age

City

Country

1

John Doe

30

New York

USA

2

Jane Doe

25

London

UK

3

Peter Lee

40

Paris

France

 

  • Select the ID, name & age of customers who are older than 25

Command:

SQL query written on a black background with colored keywords. The query selects the ID, name, and age from the Customers table where age is greater than 25.

Output:

ID

Name

Age

1

John Doe

30

3

Peter Lee

40

Worked Example

The database table Stock stores the current stock levels of products currently on sale.

ProdName

Quantity

Price

Biscuits

143

0.99

Bread

87

1.49

Milk

34

1.10

Pasta

421

0.89

Ketchup

287

2.99

Complete the SQL query to return the product name and quantity of all products that’s price is less than £1 [3]

Table with three rows labeled SELECT, FROM, and WHERE, commonly used in SQL query structure. Each label is in a separate cell in the first column.

Answer

SQL query for selecting "ProdName" and "Quantity" from "Stock" table where "Price" is less than 1, shown in a table format.

Guidance

  • Spelling of field names and table name must be exact

  • Capitalisation must match field and table names to be awarded marks

  • Table name is always in the question in different format

Responses

您的邮箱地址不会被公开。 必填项已用 * 标注