Solved

TSQL multiple select statement

Posted on 2013-01-17
7
433 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
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 7

Accepted Solution

by:
Ross Turner earned 500 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
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.

707 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