Spiritual Meaning of GENESIS 37:36
AC 4787. Verse 36. And the Midianites sold him into Egypt unto Potiphar, Pharaoh’s chamberlain, prince of the guards. "And the Midianites sold him into Egypt," signifies that those who are in some truth of simple good consulted memory-knowledges; "unto Potiphar, Pharaoh‘s chamberlain," signifies interior memory-knowledges; "prince of the guards," signifies things which are primary for interpretation.
AC 4788. And the Midianites sold him into Egypt. That this signifies that those who are in some truth of simple good consulted memory-knowledges, is evident from the representation of the Midianites, as being those who are in the truth of simple good (n. 3242, 4756); and from the signification of "Egypt," as being memory-knowledges (n. 1164, 1165, 1186, 1462, 2588, 4749); and from the signification of "selling," as being to alienate (n. 4752, 4758); and from the representation of Joseph, as being Divine truth. When this is said to be sold or alienated by those who are in the truth of simple good to memory-knowledges, which are "Egypt," it denotes that they consulted them; for those who are in the truth of simple good suffer themselves to be very much led away by the fallacies of the senses, and thus by memory-knowledges, which are therefrom.
 It was said above (verse 28) that Joseph was drawn out of the pit by the Midianites, but that he was sold to the Ishmaelites; whence it might seem that he could have been sold in Egypt only by the Ishmaelites. But the reason why he was not sold by the Ishmaelites but by the Midianites, is that the Ishmaelites represent those who are in simple good (n. 4747), and the Midianites those who are in the truth of this good. Joseph, or the Divine truth, could not be sold by those who are in good, but only by those who are in truth; for those who are in good know from good what Divine truth is, but not so those who are in truth.
 The men of the church are distinguished into two kinds--those who are in good, and those who are in truth. Those who are in good are called celestial, but those who are in truth are called spiritual. Between these two kinds there is a great difference. Those who are in good are in the affection of doing good for the sake of good, and without recompense from others; for it is recompense to them to be permitted to do good, since in so doing they perceive joy; but those who are in truth are in the affection of doing good, not for its own sake, but because it is so commanded, and for the most part they think of recompense; their joy is from this, and also from glorying.
 From this it is evident that those who do good from good, do it from internal affection; while those who do good from truth, do it from some external affection. Hence the difference is evident, namely, that the former are internal men, and the latter external. Those therefore who are internal men cannot sell, that is, alienate, the Divine truth which is represented by Joseph, because they perceive truth from good; and hence neither the fallacies of the senses, nor consequently memory-knowledges, lead them away. But those who are external men can sell or alienate it, because they do not perceive truth from good, but only know it from doctrine and teachers; and if they consult memory-knowledges, they suffer themselves to be easily led away by fallacies, for they have no inward dictate. It is for this reason that Joseph was not sold by the Ishmaelites, but by the Midianites.
AC 4789. Unto Potiphar, Pharaoh’s chamberlain. That this signifies interior memory-knowledges, is evident from the signification of a "chamberlain," as being what is interior, of which presently; and from the representation of Pharaoh, as being memory-knowledges; for by "Egypt" are signified memory-knowledges in general, as shown above (n. 1164, 1165, 1186, 1462), and in like manner by "Pharaoh;" for that which in the Word is signified by a land or a nation, is signified also by its king, he being the head of the nation. That interior memory-knowledges are what are signified by "Pharaoh‘s chamberlain," is because chamberlains were connected with the internal affairs of a king; for they were his more intimate courtiers and his more eminent officers, as is manifest also from the signification of this word in the original tongue.
AC 4790. Prince of the guards. That this signifies things which are primary for interpretation, is evident from the signification of "prince," as being what is primary (n. 1482, 2089). That the "prince of the guards" here denotes things primary for interpretation, is because the subject treated of is Divine truth, which was sold by those who were in the truth of simple good by their consulting memory-knowledges; whence came a wandering and estrangement from Divine truth, and hence interpretations from the sense of the letter of the Word (n. 4783); and by "guards" are signified those things which minister.