A join statement, like a select statement, starts with the keyword select. The columns named after the select keyword are the columns to be included in the query results, in their desired order.
select au_fname, au_lname, pub_name from authors, publishers
select au_fname, au_lname, pub_name from authors, publishers where authors.city = publishers.city
Though neither of the city columns is printed in the results, SAP ASE needs the table name to perform the comparison.
select * from authors, publishers where authors.city = publishers.city
au_id au_lname au_fname phone address city state postalcode contract pub_id pub_name city state ----------- -------- -------- ------------ --------------------- ---------- ----- ---------- -------- ------ -------------------- ---------- ----- 238-95-7766 Carson Cheryl 415 548-7723 589 Darwin Ln. Berkeley CA 94705 1 1389 Algodata Infosystems Berkeley CA 409-56-7008 Bennet Abraham 415 658-9932 223 Bateman St Berkeley CA 94705 1 1389 Algodata Infosystems Berkeley CA (2 rows affected)
The output shows a total of 2 rows with 13 columns each. Because of the length of the rows, each takes up multiple horizontal lines. Whenever “*” is used, the columns in the results appear in the order in which they were stated in the create statement that created the table.
select au_lname, au_fname from authors, publishers where authors.city = publishers.city
Just as in any select statement, column names in the select list and table names in the from clause must be separated by commas.