0

I have a users table and a locations table.

The locations table looks like:

Location
-id
-name

I want an output that has all users, repeated for each location so like:

user1 location1
user2 location1
user3 location1
user1 location2
user2 location2
user3 location2

How can I create a SELECT query like the above?

cool breeze
  • 4,461
  • 5
  • 38
  • 67
  • `SELECT u.name, l.name FROM users u,location l` – Lukasz Szozda Dec 15 '15 at 19:31
  • 1
    `Select * from location cross join users` one of my favorite [links](http://blog.codinghorror.com/a-visual-explanation-of-sql-joins/) for join types and explainations – xQbert Dec 15 '15 at 19:32
  • 1
    Possible duplicate of [SQL JOIN and different types of JOINs](http://stackoverflow.com/questions/17946221/sql-join-and-different-types-of-joins) – Tab Alleman Dec 15 '15 at 19:39

1 Answers1

2

I think what you are looking for is a cross join:

SELECT Users.Name, Locations.Name
FROM Users 
    CROSS JOIN Locations
test
  • 2,589
  • 2
  • 24
  • 52