OceanBase logo

OceanBase

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Resources

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS

OceanBase Cloud

OceanBase Database

Tools

Connectors and Middleware

QUICK START

OceanBase Cloud

OceanBase Database

BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Company

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

International - English
中国站 - 简体中文
日本 - 日本語
Sign In
Start on Cloud

A unified distributed database ready for your transactional, analytical, and AI workloads.

DEPLOY YOUR WAY

OceanBase Cloud

The best way to deploy and scale OceanBase

OceanBase Enterprise

Run and manage OceanBase on your infra

TRY OPEN SOURCE

OceanBase Community Edition

The free, open-source distributed database

OceanBase seekdb

Open source AI native search database

Customer Stories

Real-world success stories from enterprises across diverse industries.

View All
BY USE CASES

Mission-Critical Transactions

Global & Multicloud Application

Elastic Scaling for Peak Traffic

Real-time Analytics

Active Geo-redundancy

Database Consolidation

Comprehensive knowledge hub for OceanBase.

Blog

Live Demos

Training & Certification

Documentation

Official technical guides, tutorials, API references, and manuals for all OceanBase products.

View All
PRODUCTS
OceanBase CloudOceanBase Database
ToolsConnectors and Middleware
QUICK START
OceanBase CloudOceanBase Database
BEST PRACTICES

Practical guides for utilizing OceanBase more effectively and conveniently

Learn more about OceanBase – our company, partnerships, and trust and security initiatives.

About OceanBase

Partner

Trust Center

Contact Us

Start on Cloud
编组
All Products
    • Databases
    • iconOceanBase Database
    • iconOceanBase Cloud
    • iconOceanBase Tugraph
    • iconInteractive Tutorials
    • iconOceanBase Best Practices
    • Tools
    • iconOceanBase Cloud Platform
    • iconOceanBase Migration Service
    • iconOceanBase Developer Center
    • iconOceanBase Migration Assessment
    • iconOceanBase Admin Tool
    • iconOceanBase Loader and Dumper
    • iconOceanBase Deployer
    • iconKubernetes operator for OceanBase
    • iconOceanBase Diagnostic Tool
    • iconOceanBase Binlog Service
    • Connectors and Middleware
    • iconOceanBase Database Proxy
    • iconEmbedded SQL in C for OceanBase
    • iconOceanBase Call Interface
    • iconOceanBase Connector/C
    • iconOceanBase Connector/J
    • iconOceanBase Connector/ODBC
    • iconOceanBase Connector/NET
icon

OceanBase Database

SQL - V4.3.5

    Download PDF

    OceanBase logo

    The Unified Distributed Database for the AI Era.

    Follow Us
    Products
    OceanBase CloudOceanBase EnterpriseOceanBase Community EditionOceanBase seekdb
    Resources
    DocsBlogLive DemosTraining & Certification
    Company
    About OceanBaseTrust CenterLegalPartnerContact Us
    Follow Us

    © OceanBase 2026. All rights reserved

    Cloud Service AgreementPrivacy PolicySecurity
    Contact Us
    Document Feedback
    1. Documentation Center
    2. OceanBase Database
    3. SQL
    4. V4.3.5
    iconOceanBase Database
    SQL - V 4.3.5
    SQL
    KV
    • V 4.4.2
    • V 4.3.5
    • V 4.3.3
    • V 4.3.1
    • V 4.3.0
    • V 4.2.5
    • V 4.2.2
    • V 4.2.1
    • V 4.2.0
    • V 4.1.0
    • V 4.0.0
    • V 3.1.4 and earlier

    FULL JOIN queries

    Last Updated:2026-04-09 02:53:54  Updated
    share
    What is on this page
    Background information
    Syntax
    Examples
    Simple FULL JOIN queries
    FULL JOIN queries with a WHERE clause
    References

    folded

    share

    A FULL JOIN query is a full (outer) join query that returns all rows in all joins, no matter whether they match.

    Background information

    An OUTER JOIN query uses a comparison operator to compare the data in two tables. The join results include the rows that meet the join conditions and those do not meet the join conditions.

    OUTER JOIN queries include FULL JOIN queries, LEFT JOIN queries, and RIGHT JOIN queries. An outer join returns all the rows that meet the join conditions. In addition, it returns unused rows of one table and fills NULL in the corresponding positions in the other table.

    This topic describes how to use FULL JOIN queries. For more information about LEFT JOIN queries and RIGHT JOIN queries, see LEFT JOIN queries and RIGHT JOIN queries.

    Syntax

    Generally, an OUTER JOIN statement contains a left-side table and a right-side table. The leftmost table in the JOIN clause is the left-side table, and the rightmost table in the JOIN clause is the right-side table.

    The syntax is as follows:

    SELECT select_list FROM table_name1 FULL JOIN table_name2 ON join_condition
    [ WHERE query_condition ]
    [ ORDER BY column_list ];
    

    Here, table_name1 is the left-side table and table_name2 is the right-side table.

    Examples

    Create a table and insert proper data into the table.

    obclient [SYS]> CREATE TABLE tbl_a(id NUMBER NOT NULL PRIMARY KEY, name VARCHAR2(50));
    Query OK, 0 rows affected
    
    obclient [SYS]> CREATE TABLE tbl_b(num NUMBER NOT NULL PRIMARY KEY, value NUMBER);
    Query OK, 0 rows affected
    
    obclient [SYS]> INSERT INTO tbl_a VALUES(1,'ab'),(2,'cd'),(3,'ef'),(4,'gh');
    Query OK, 6 rows affected
    Records: 6  Duplicates: 0  Warnings: 0
    
    obclient [SYS]> INSERT INTO tbl_b VALUES(1,1001),(3,1003),(5,1005);
    Query OK, 4 rows affected
    Records: 4  Duplicates: 0  Warnings: 0
    

    Simple FULL JOIN queries

    If no matching row can be found in the left-side table or right-side table for a FULL JOIN query, the system will automatically fill in NULL.

    For example, execute a FULL JOIN query on the tbl_a and tbl_b tables and obtain the results.

    obclient [SYS]> SELECT * FROM tbl_a;
    +----+------+
    | ID | NAME |
    +----+------+
    |  1 | ab   |
    |  2 | cd   |
    |  3 | ef   |
    |  4 | gh   |
    +----+------+
    4 rows in set
    
    obclient [SYS]> SELECT * FROM tbl_b;
    +-----+-------+
    | NUM | VALUE |
    +-----+-------+
    |   1 |  1001 |
    |   3 |  1003 |
    |   5 |  1005 |
    +-----+-------+
    3 rows in set
    
    obclient [SYS]> SELECT * FROM tbl_a FULL JOIN tbl_b ON tbl_a.id=tbl_b.num;
    +------+------+--------+-------+
    | ID   | NAME |   NUM  | VALUE |
    +------+------+--------+-------+
    |    1 | ab   |      1 |  1001 |
    |    2 | cd   |   NULL |  NULL |
    |    3 | ef   |      3 |  1003 |
    |    4 | gh   |   NULL |  NULL |
    | NULL | NULL |      5 |  1005 |
    +------+------+--------+-------+
    5 rows in set
    

    In this example, the tbl_a table does not contain any row with the value 5. Therefore, this row is filled with NULL in the returned result. The tbl_b table does not contain any row with the value 2 or 4. Therefore, these two rows are filled with NULL in the returned result.

    FULL JOIN queries with a WHERE clause

    You can use a FULL JOIN query to obtain the join result and then use the WHERE clause to filter the result.

    For example, execute a FULL JOIN query on the tbl_a and tbl_b tables and return the data that meets the value=1003 condition in the tbl_b table.

    obclient [SYS]> SELECT * FROM tbl_a;
    +----+------+
    | ID | NAME |
    +----+------+
    |  1 | ab   |
    |  2 | cd   |
    |  3 | ef   |
    |  4 | gh   |
    +----+------+
    4 rows in set
    
    obclient [SYS]> SELECT * FROM tbl_b;
    +-----+-------+
    | NUM | VALUE |
    +-----+-------+
    |   1 |  1001 |
    |   3 |  1003 |
    |   5 |  1005 |
    +-----+-------+
    3 rows in set
    
    obclient [SYS]> SELECT * FROM tbl_a FULL JOIN tbl_b ON tbl_a.id=tbl_b.num WHERE tbl_b.value=1003;
    +----+------+-----+-------+
    | ID | NAME | NUM | VALUE |
    +----+------+-----+-------+
    |  3 | ef   |   3 |  1003 |
    +----+------+-----+-------+
    1 row in set
    

    References

    • INNER JOIN queries

    • LEFT JOIN queries

    • RIGHT JOIN queries

    Previous topic

    INNER JOIN queries
    Last

    Next topic

    LEFT JOIN queries
    Next
    What is on this page
    Background information
    Syntax
    Examples
    Simple FULL JOIN queries
    FULL JOIN queries with a WHERE clause
    References