sql - LIKE in INNER JOIN doesn't work -


while practicing in sql here http://www.w3schools.com/sql/trysql.asp?filename=trysql_select_join made task myself - need compose table using inner join contain customerid, employeeid, contactname of customer, , employee's last , first names employee's first name contained in customer's contact name. following doesn't give output:

select distinct customers.customerid, customers.contactname customercontactname, employees.employeeid, employees.firstname employeefirstname, employees.lastname employeelastname customers join employees on customers.contactname "%"+employees.firstname+"%" 

though one:

select distinct customers.customerid, customers.contactname customercontactname, employees.employeeid, employees.firstname employeefirstname, employees.lastname employeelastname customers join employees on customers.contactname "%janet%" , employees.firstname "%janet%" 

gives correct output 1 case. miss or w3schools' issue?

this works

select distinct customers.customerid, customers.contactname  customercontactname, employees.employeeid, employees.firstname employeefirstname, employees.lastname employeelastname customers inner join employees on customers.contactname "%"+employees.firstname+"%" 

results in:

number of records: 3 customerid  | customercontactname   | employeeid    | employeefirstname | employeelastname 41          | annette roulet        | 9             | anne              | dodsworth  67          | janete limeira        | 3             | janet             | leverling  68          | michael holz          | 6             | michael           | suyama  

looks you've got explicitly tell it inner join. though should not necessary. thats w3schools you!


Comments