Solved

Combine two queries

Posted on 2011-09-19
3
340 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
[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
  • 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

How Blockchain Is Impacting Every Industry

Blockchain expert Alex Tapscott talks to Acronis VP Frank Jablonski about this revolutionary technology and how it's making inroads into other industries and facets of everyday life.

Question has a verified solution.

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

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
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.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

636 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