| Performing Queries Using SQL |
| Querying Multiple Tables
|
| Specifying Columns That Appear in Multiple
Tables
To join two or more tables, you must specify a prefix in the SELECT statement if both tables that you are querying contain like-named columns.
In the SELECT statement below, the SELECT clause specifies the prefix
BldgInfo for the column |
proc sql;
select bldginfo.id,lastname,building,room,extension
from emplib.payroll,emplib.bldginfo
where bldginfo.id=payroll.id
order by lastname;
|
In this case, the column ID
is read from EmpLib.BldgInfo. For columns that are
not like-named, simply specify the column name. Separate all column names
with commas. |
![]() ![]() |
|
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.