SQLTeam.com | Weblogs | Forums

Is it possible in SQL Join


#1

DECLARE @PRODUCT TABLE
(

line VARCHAR (50),
description VARCHAR (50)
)

INSERT @PRODUCT

SELECT 'AIRFILBSPL','Air Filter Base Plate' UNION ALL
SELECT 'AIRFILCOLD','Air Filter- Cold Air Intake' UNION ALL
SELECT 'AIRFILSEAL','Air Filter Sealing Grease' UNION ALL
SELECT 'AIRFILTER', 'Air Filter' UNION ALL
SELECT 'CLDTR','Cold Air Intake' UNION ALL
SELECT 'CLDTR','Cold Air Intake' UNION ALL
SELECT 'ABSCAB','ABS Cable Bracket'

SELECT * FROM @PRODUCT

DECLARE @DRIVER TABLE
(

BaseType VARCHAR (50),
NeededType VARCHAR (50)
)

INSERT @DRIVER

SELECT 'Cold Air Intake','Air Filter%' UNION ALL
SELECT 'ABSCAB', 'ABS Cable%'

SELECT * FROM @DRIVER

/*
I Want to join this two table on column (description- BaseType) and once on column (description- NeededType)
*/
Expected Output

Thanks You Very Much For Help


#2

It looks like in your example output you have a join on @product.line = @driver.basetype.

is that correct?


#3

looks more like

FROM     @DRIVER dr
    INNER JOIN @PRODUCT pr    
    ON    pr.[description]    like dr.NeededType