extracting column3 value from 2 existing columns in sql 2008

Hello, newbie to SQL (SQL server 2008).

I need to extract the value in a column using the concatenation of 2 existing values in 2 different columns. for example:

Column 1 Column 2  Column3
Valuea       Valueb       Extract Val

Need to pull the value "extract val" by reading the key of concat of "valuea" and "valueb"

Is that possible via query?

Thanks,

rm103
rm103Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Give this a whirl and let us know if it works...
SELECT Column3
FROM YourTable
WHERE Column1 = 'Valuea' AND Column2 = 'Valueb'

Open in new window

0
PortletPaulfreelancerCommented:
yep, probably no need for "concat" if the data is in those 3 columns as shown, and your use of "extract" is probably just "select" in SQL

SELECT id, Column1, Column2, Column3
FROM yourtable
WHERE Column1 = 'Valuea' AND Column2 = 'Valueb'

would produce something like this

id     Column1 Column2  Column3
1       Valuea      Valueb     Extract Val
2       Valuea      Valueb     another Wanted value


If you just want Column3 then just adjust the SELECT clause

SELECT Column3
FROM yourtable
WHERE Column1 = 'Valuea' AND Column2 = 'Valueb'

Column3
Extract Val
another Wanted value


Note If you specifically just want that one column AND a single row (for 'Extract Val') then you may need more than just Valuea and Valueb as conditions in the WHERE clause. This totally depends on the data in your table, in my example I would need to also use id=1

SELECT Column3
FROM yourtable
WHERE Column1 = 'Valuea' AND Column2 = 'Valueb' AND id = 1

Column3
Extract Val
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2008

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.