See below DDL:
CREATE TABLE dbaddress
(aid integer identity not null, link_id int, link_type char, primary key (aid))
CREATE TABLE dbDoorSupervisor
(did integer identity not null, name varchar(30), primary key (did))
CREATE TABLE dbLicensee
(lid integer identity not null, name varchar(30), primary key (lid))
INSERT INTO dbDoorSupervisor (name) values ('Ian')
INSERT INTO dbLicensee (name) values ('Maria')
INSERT INTO dbaddress (link_id, link_type) values (1,'D')
INSERT INTO dbaddress (link_id, link_type) values (1,'L')
I am trying to get the name of the door manager or Licensee depending on the Address.AID address that is supplied. For example, if help 1 is provided in the WHERE clause, then Ian is returned from the door manager table, however if help 2 is provided in the WHERE clause, then Maria is returned from the Licensee table.
I know that you can use CASE statements in the SELECT clause, but can you use them in the FROM clause ie to join from the address to the licensee or to the door manager, depending on the AID provided?
source
share