Solved

Combine two queries

Posted on 2011-09-19
3
331 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

Industry Leaders: 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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

685 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