Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Return multiple entries from a SELECT

Status
Not open for further replies.

Belle19

Programmer
Jun 2, 2006
11
US
I need to return two rows for every row from a table. For instance, the table layout could be:

Cust_name Cust_Address Check_no
John 123 Main St. 1234
Jane 456 Eve St. 5678

My results that I am attempting to get back need to be as such:

John 123 Main St. 1234
John 123 Main St. 1234
Jane 456 Eve St. 5678
Jane 456 Eve St. 5678

Any ideas on a way to do this without complicating matters????
 
Code:
select Cust_name, Cust_Address, Check_no
  from daTable
union all
select Cust_name, Cust_Address, Check_no
  from daTable
alternatively...
Code:
select Cust_name, Cust_Address, Check_no
  from daTable
cross
  join ( select 1 union select 937 ) as two




r937.com | rudy.ca
 
Code:
Select Fields...
From   Table 
       Cross Join 
         (
         Select 1 As DupNumber 
         union All 
         Select 2
         ) As A


-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Thanks for the responses!!!!

I tried this:

select check_number, customer_name, check_amount, fl_flag
from process_76
where fl_flag = '1'
union all
select check_number, customer_name, check_amount, fl_flag
from process_76
where fl_flag = '1'

It returns the rows that I need however is there anyway to group the rows together that are alike???
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top