Solved

Combine two queries

Posted on 2011-09-19
3
300 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
Comment Utility

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
Comment Utility
or like this


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

Expert Comment

by:Pratima Pharande
Comment Utility
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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
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…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

771 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

15 Experts available now in Live!

Get 1:1 Help Now