i have 2 table. first table for cust. expml :
id | name |
---|---|
12 | Anna |
23 | Beth |
and the last one is for stuff
id_stuff | type |
---|---|
1 | Knife |
2 | mug |
3 | fork |
i want to show data in potgresql like :
id_stuff | name | type |
---|---|---|
12 | Anna | Knife |
12 | Anna | mug |
12 | Anna | fork |
23 | Beth | Knife |
23 | Beth | mug |
23 | Beth | fork |
thanks.
CodePudding user response:
That is a cross join or Cartesian product:
SELECT cust.id, cust.name, stuff.type
FROM cust CROSS JOIN stuff;
CodePudding user response:
You can simply select all the tables and you get the same results to CROSS JOIN.
SELECT cust.id, cust.name, stuff.id_stuff, stuff.type FROM cust, stuff