JOIN Queries

The DATABASICS JDBC driver only supports inner joins.

Inner Join

Returns only rows from both tables that match the given join condition.

SELECT * FROM OpUnit O, Department D WHERE D.optCode = O.optCode

 


 

Joins with matching column names

We offer support for only inner joins in JDBC, meaning we cannot perform other types of joins. Additionally, when displaying the output of an inner join, we will only show columns with unique names. If there are columns with duplicated names, we will only display information from the first table involved in

 

Example:

SELECT * FROM OpUnit O, Department D WHERE D.optCode = O.optCode

 

Output:

 

Issue:

Both tables contain the name column, so the API only returns the output for the first table OpUnit.name

 

Resolution:

If we need the name for both tables we must force it from the select columns by using an alias like D.name AS departmentName.

SELECT D.name As departmentName, * FROM OpUnit O, Department D WHERE D.optCode = O.optCode

 

Output:

 


 

Debugging Joins

For joins with multiple tables, it can sometimes be difficult to see why some matching columns fail to show. To help the debugging process you can easily see only one table of the join at a time by using the following.

The D.* will only output the Department columns. Likewise, the O.* would only output the OpUnit columns so you can easily see that both tables contained the name field.

2024 DATABASICS, Inc