Solved

Combine two queries

Posted on 2011-09-19
3
309 Views
Last Modified: 2012-05-12
Thank you for looking at my question,

I have two queries:
'SELECT txtPartNo, intBar AS First, intOrdinal FROM tblPartsList WHERE intOrdinal = 1;'
and
'SELECT txtPartNo, intBar AS Second, intOrdinal FROM tblPartsList WHERE intOrdinal = 2;'


How do I combine the query to end up with three columns - txtPartNo. First and Second

Thank you
0
Comment
Question by:Crxfrd
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Haris Djulic earned 500 total points
ID: 36559114

select txtPartNo,First, Second from

(

SELECT txtPartNo, intBar AS First, intOrdinal FROM tblPartsList WHERE intOrdinal = 1
union
SELECT txtPartNo, intBar AS Second, intOrdinal FROM tblPartsList WHERE intOrdinal = 2

)
a
0
 
LVL 15

Expert Comment

by:Haris Djulic
ID: 36559121
or like this


SELECT txtPartNo, intBar AS First, intOrdinal FROM tblPartsList WHERE intOrdinal in ( 1,2)
0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 36559137
try this

SELECT txtPartNo, intBar AS First, intOrdinal FROM tblPartsList WHERE intOrdinal = 1 OR 2

try this

SELECT txtPartNo, intBar AS First, intOrdinal FROM tblPartsList WHERE intOrdinal = 1 OR intOrdinal = 2
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

947 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now