How does Matomo track previous visits before registration

Hi, is there anyway we can get the data from db for the visits before registration? As I noticed, after registration the visitorid is changed for that visit based on new user_id assigned, for this case, i face difficulties in getting previous visits based on visitorid.