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
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
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'
TABLE.COL2 = 'abc' and TABLE.COL3 = 'def'
or
TABLE.COL2 = 'abc' and TABLE.COL3 = 'hijk'
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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'
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'
ASKER
Thanks I Ross, appreaciate it
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' )