Amplify records

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have 10 records with 10 vehicles.
For example: Ford Explore
Honda Accord
.............


I have a table with 100 zipcodes.
My question is how can I amplify the 10 Vehicles by 100 zipcodes to generate
10*100 records.

I mean: 48152 Ford Explore
48152 Honda Accord
...................

44552 Ford Explore
44552 Honda Accord
....................


44444 Ford Explore
44444 Honda Accord
..................

Thanks a lot!

Lily
 
Lily said:
I have 10 records with 10 vehicles.
For example: Ford Explore
Honda Accord
.............


I have a table with 100 zipcodes.
My question is how can I amplify the 10 Vehicles by 100 zipcodes to generate
10*100 records.

I mean: 48152 Ford Explore
48152 Honda Accord
...................

44552 Ford Explore
44552 Honda Accord
....................


44444 Ford Explore
44444 Honda Accord
..................

Thanks a lot!

Lily

Try:

SELECT z.zipcode, v.vehicle_name
FROM zipcodes AS z, vehicles AS v ;

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
 
Use a Cross Join:

select * from Vehicles CROSS JOIN ZipCodes

You will get the cartesian product of both tables.
 
Back
Top