?
Solved

How to repeat rows over and over again

Posted on 2007-11-15
4
Medium Priority
?
765 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 500 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

Independent Software Vendors: 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

Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
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.​
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 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