Reputation: 99
I'm trying to write a query to find matches from two tables having the same area code for telephone number. e.g
Employee(name, telephone#)
Customer(name, telephone#)
Need to find name of employees with the same telephone area code(xxx-yyy-zzzz) as that of customer(xxx-yyy-zzzz). I can't specify the area code myself. Query should evaluate that. Maybe something like "LIKE" can be used?
Upvotes: 0
Views: 275
Reputation: 49260
Use substr
and join
on the first 3 characters of the telephone column.
select e.name
from employee e
inner join customer c on substr(e.telephone, 1, 3) = substr(c.telephone, 1, 3)
Upvotes: 3