4D v11 SQL includes functionality which allows developers to directly include SQL statements in their methods through the BEGIN SQL and END SQL commands. One of the SQL clauses not included in 4D is JOIN.
For information on the SQL clause JOIN check out its wikipedia entry:
This clause is used in SQL to effectively create a relationship between two tables. Use of a JOIN in 4D can be especially useful because there does not have to be any pre-existing relationship between tables or fields to use the JOIN clause. Instead of using the JOIN clause a WHERE clause can be included in a SELECT statement from two tables. The WHERE clause can be used to simulate JOIN by setting fields from two separate tables equal to each other. This effectively simulates the behavior of a SQL JOIN statement.
The following code would get all records from the CUSTOMERS table and INVOICES table where the ID field in CUSTOMERS matches the CUSTID field in INVOICES. It effectively creates a relationship between the two tables. This example also queries for customers named Josh Fletcher, so only invoices from that customer will be returned:
FROM CUSTOMERS, INVOICES
WHERE CUSTOMERS.ID = INVOICES.CUSTID
& CUSTOMERS.NAME = 'Josh Fletcher';
For more sample code on creating SELECT statements with the WHERE clause used as to simulate a JOIN clause see the 4D v11 SQL online reference at the following link: