Solved

How to repeat rows over and over again

Posted on 2007-11-15
4
764 Views
Last Modified: 2008-02-01
I have this query that lists a given list of codes for a project

76011
76013
76015
76016

I want to have this query repeat 3 times so it comes out like this

76011
76013
76015
76016
76011
76013
76015
76016
etc..

0
Comment
Question by:PROJHOPE
[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
  • 2
4 Comments
 
LVL 27

Accepted Solution

by:
MikeToole earned 125 total points
ID: 20290333
A new query wil the following SQL:

select Code from MyQuery
Union
select Code from MyQuery
Union
select Code from MyQuery
0
 

Author Comment

by:PROJHOPE
ID: 20290360
Sorry not explaining this correctly

Here is my query

select cost_element_id from DBSproj.dbo.component_cost_element
where component_id = '8933'
and project_id = 'INTL WITH TAS'

Results are this:

70573    
76013    
76023    
76033    
76053    
76063    
76093    
76313    
76333    
76353    
76373    
76393    
76473    
76493    
76613    
86013    
86033    
86933    

I want it to be

70573    
76013    
76023    
76033    
76053    
76063    
76093    
76313    
76333    
76353    
76373    
76393    
76473    
76493    
76613    
86013    
86033    
86933
70573    
76013    
76023    
76033    
76053    
76063    
76093    
76313    
76333    
76353    
76373    
76393    
76473    
76493    
76613    
86013    
86033    
86933    

etc...

If I do the union I simply retrieve only the 18

0
 

Author Comment

by:PROJHOPE
ID: 20290374
Ok I got it...UNION ALL not just UNION
0
 
LVL 27

Expert Comment

by:MikeToole
ID: 20290416
Oops, you got it!, I forget that my unions usually retrieve distinct rows, so no requirement for ALL.
0

Featured Post

Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

Question has a verified solution.

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

Introduction Hopefully the following mnemonic and, ultimately, the acronym it represents is common place to all those reading: Please Excuse My Dear Aunt Sally (PEMDAS). Briefly, though, PEMDAS is used to signify the order of operations (http://en.…
Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

726 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