Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

TSQL multiple select statement

Posted on 2013-01-17
7
Medium Priority
?
482 Views
Last Modified: 2013-01-17
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
0
Comment
Question by:Tech315
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 40

Expert Comment

by:lcohan
ID: 38789069
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' )
0
 
LVL 21

Expert Comment

by:Dale Burrell
ID: 38789074
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.
0
 
LVL 8

Expert Comment

by:H
ID: 38789100
where
TABLE.COL2 = 'abc' and TABLE.COL3 = 'def'
or
TABLE.COL2 = 'abc' and TABLE.COL3 = 'hijk'
0
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 
LVL 7

Accepted Solution

by:
Ross Turner earned 2000 total points
ID: 38789107
SELECT

TABLE.COL1            AS [EXT_LA],

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

WHERE TABLE.COL2 = 'def' AND TABLE.COL3 in  ('def','hijk' )
0
 
LVL 40

Expert Comment

by:lcohan
ID: 38789108
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' )
0
 
LVL 8

Expert Comment

by:H
ID: 38789122
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'
0
 

Author Closing Comment

by:Tech315
ID: 38789229
Thanks I Ross, appreaciate it
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question