Oracle/PLSQL: SELECT Statement

SQL: SELECT Statement

The SQL SELECT statement allows you to retrieve records from one or more tables in your SQL database.

The syntax for the SQL SELECT statement is:

SELECT columns
FROM tables
WHERE predicates;

SQL SELECT Statement - Select all fields from one table example

Let's take a look at how to use the SQL SELECT statement to select all fields from a table.

SELECT *
FROM suppliers
WHERE city = 'Newark';

In this SQL SELECT statement, we've used * to signify that we wish to view all fields from the suppliers table where the supplier resides in Newark.

SQL SELECT Statement - Selecting individual fields from one table example

You can also use the SQL SELECT statement to select individual fields from the table, as opposed to all fields from the table.

For example:

SELECT name, city, state
FROM suppliers
WHERE supplier_id > 1000;

This SQL SELECT statement would return only the name, city, and state fields from the suppliers table where the supplier_id value is greater than 1000.

SQL SELECT Statement - Select fields from multiple tables example

You can also use the SQL SELECT statement to retrieve fields from multiple tables.

SELECT orders.order_id, suppliers.name
FROM suppliers, orders
WHERE suppliers.supplier_id = orders.supplier_id;

This SQL SELECT statement joins two tables together to gives us a result set that displays the order_id and supplier name fields where the supplier_id value existed in both the suppliers and orders table.

Learn more about SQL joins.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值