I have these two tables in MySQL database:
tbl_hashs >
h_id | r_id | hash |
---|---|---|
1 | 122 | xx |
2 | 123 | xx |
tbl_sandbox >
h_id | r_id | hash |
---|---|---|
NULL | NULL | xx |
finally I want to have this table:
query result should be like >>>
h_id | r_id | hash |
---|---|---|
1 | 122 | xx |
1 | 123 | xx |
2 | 122 | xx |
2 | 123 | xx |
I think something like "Cartesian multiplication" can help me. but I can't do it in MySQL. please somebody help me with proper query.
CodePudding user response:
SELECT
t1.h_id,
t2.r_id,
t2.hash
FROM tbl_hashs t1
CROSS JOIN tbl_hashs t2
ORDER BY t1.h_id
But I did not use tbl_sandbox
, is that good ?
https://dbfiddle.uk/?rdbms=mysql_8.0&fiddle=32926caddc063c2adcbc03944ce489ce