V
V
Vadim Bakhtin2016-06-02 12:14:26
MySQL
Vadim Bakhtin, 2016-06-02 12:14:26

How to build a table based on existing ones?

1ca190930223510e5a5bc78db066081e.png
There is such a structure of tables, how to build a new table with supplier numbers and pairs of part numbers, such that some supplier supplies both specified parts. At the same time, pairs of the form 1 and 2, as well as 2 and 1, are considered the same?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Entelis, 2016-06-02
@from2003

If I understand correctly, then all possible pairs of parts that are supplied by one supplier

SELECT t1.Snum, t1.Pnum, t2.Pnum FROM `spj` as t1
join spj as t2 on t1.Snum = t2.Snum and t1.Pnum != t2.Pnum

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question