If jesus was the son of god why do two of the gospels give his lineage through David via Joseph?

Don't get me wrong - like last time - I am not mocking christianity (or any other religion) I seek merely to understand. But if two if the gospels disagree with each other on the parentage of the son of God as the son of Joseph then I don't understand what the inerrant word of God is telling me.
Update: As I understand it Mary was of the trbe of benjamin, how can the second lineage (which ends with Joseph not Mary be of the line of David (tribe of Judha)
Update 2: Sorry Benjie read
18 answers 18