Link to home
Start Free TrialLog in
Avatar of Tech315
Tech315

asked on

TSQL multiple select statement

Hi have a multiple select statement as follows:
SELECT

TABLE.COL1            AS [EXT_LA],

TABLE.COL2             AS [EXT_LAO],
 
TABLE.COL3            AS[EXT_LA#]

I need to only pull 'abc' from col2 and 'def', and 'hijk' from col3 how would i go about doing that?

Thanks
Avatar of lcohan
lcohan
Flag of Canada image

SELECT

TABLE.COL1            AS [EXT_LA],

TABLE.COL2             AS [EXT_LAO],
 
TABLE.COL3            AS[EXT_LA#]

WHERE TABLE.COL2 = 'def' AND (TABLE.COL3 = 'def' OR TABLE.COL3 = 'hijk' )
Can you provide some more information please for example when you say you only need to pull 'abc' from col2, do you mean the value should always be 'abc' or you only want to display the value when col2 = 'abc' or what? Please provide an example with real data.
where
TABLE.COL2 = 'abc' and TABLE.COL3 = 'def'
or
TABLE.COL2 = 'abc' and TABLE.COL3 = 'hijk'
ASKER CERTIFIED SOLUTION
Avatar of Ross Turner
Ross Turner
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Sorry I missed the FROM clause:

SELECT

TableName.COL1            AS [EXT_LA],
TableName.COL2             AS [EXT_LAO],
TableName.COL3            AS[EXT_LA#]

FROM TableName
WHERE TableName.COL2 = 'def' AND (TableName.COL3 = 'def' OR TableName.COL3 = 'hijk' )
Select
TABLE.COL1 AS [EXT_LA], TABLE.COL2 AS [EXT_LAO],  TABLE.COL3 AS[EXT_LA#]
From TABLE
where
TABLE.COL2 = 'abc' and TABLE.COL3 = 'def'
or
TABLE.COL2 = 'abc' and TABLE.COL3 = 'hijk'
Avatar of Tech315
Tech315

ASKER

Thanks I Ross, appreaciate it