Solved

Need help writing a query

Posted on 2008-10-17
2
193 Views
Last Modified: 2010-03-20
Hi, I have 2 tables.  Tabel A has an Id column and then 4 columns labed R1, R2, R3 and R4.  I have another table B, I have and Id column and a Rid column.  The B.id column could be have muliple records of the same id up to at most 4 rows.  
I want to write the table B 's Rid it columns value to table A's Rn columns matching their A.id = B.id
Take the 1st match row from table B's Rid value and write it o table A's R1 column.  If there is a 2nd match row then write the table B's Rid value and write it o table A's R2 column.   Repeat until we runs out of the match.
Is it possible to write a query like this?  Thank you.
0
Comment
Question by:lapucca
2 Comments
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 500 total points
ID: 22746932
"Take the 1st match row from table B's Rid "

What do you want to determine the FIRST column?  Is there anther field to order by?  Also, if you provide your column/table names it would be easier, this may get a tiny bit complex so it may be easier for me to just write it.
0
 

Author Comment

by:lapucca
ID: 22746970
I realize that it would be just easier if I just write this in C# since I'm not so familiar with SQL now, and I'm done but am debugging the code.  Thank you very much.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

813 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

14 Experts available now in Live!

Get 1:1 Help Now