From an older post of mine:
What makes Zechariah 12:10 so difficult is that its Hebrew syntax can be parsed and understood in a myriad of ways, resulting in quite a few different renderings in the Greek versions. The best discussion of the complexities involved in the text of this verse can be found in M. J. J. Menken's Old Testament Quotations in the Fourth Gospel: Studies in Textual Form (1996), pp. 168-178. One common way of translating the MT as it was vocalized by the Masoretes is "They will look on me (hbytw 'ly) whom they have stabbed through ('t 'shr-dqrw)". The version closest to this reading is that of Theodotion, which survives in two variant forms: "They shall look on me (epiblepsontai pros me) whom they have pierced (hon exekentésen)" and "They shall look on me, to whom they have pierced (eis hon exekentésen)". The Latin Vulgate understands the verse similarly: "They will look to me (aspicient ad me) whom they have pierced (quem confixerunt)". This reading however is exegetically difficult because there is nothing elsewhere in the text about the Jews piercing God; even worse is the fact that reference switches in the next main clause from the first person to the third. The author of the gospel of John read the text differently. He vocalized 'ly as 'eley (poetic form of the preposition "to") instead of the Masoretic 'elay "on me" (a minority of MT MSS, incidentally, vocalize 'ly as 'eley), and translated 'eley with the Greek preposition eis: "They will look (opsontai) to the one whom they pierced (eis hon exekentésen)". The second Theodotionic variant thus appears to be a compromise between these two readings. The Johannine version no longer has gaze directed at God per se, and it lacks the problem of pronoun reference shifting from the first to the third person. Aside from the ambiguity with 'ly, the grammatical phrase 't 'shr is also problematic. The above translations take it in its usual sense as heading an accusative relative clause. But 't "with" can function outside the relative clause as setting up a double object construction. The translation of Aquila understands the text in this sense, "They will look on me with the one whom they pierced (sun hó exekenteesan)". Here 't is rendered with sun "with", sharply distinguishing "the one whom they pierced" from God. Contrary to how the author of John understands the scripture, the pierced one is not the object of gaze in Aquila; the pierced one rather is accompanying those who are gazing at God. Yet another way of understanding the Hebrew can be found in the LXX. The wording is quite unusual at first glance because of how the second verb is represented: "They shall look to me (epiblepsontai pros me) because they have danced triumphantly (anth' hón katórkhesanto)". The dancing actually makes sense in the context of the chapter because v. 10 follows the depiction of Jewish victory over their enemies, but this is a textual corruption in the Vorlage or the translator misread the verb; here dqrw is misread as rqdw "they have danced". If we substitute the correct verb, the sense is rather: "They shall look to me because they have pierced [others] (anth' hón exekentésen)". This also makes very good sense of the context because this follows the slaughtering of the nations by the "clans of Judah" (v. 6), and the people look to their God and mourn those they killed like their own children. The LXX anth' hón "because" (which occurs frequently as a causal conjunction in the LXX, cf. Genesis 22:18 LXX, 26:5 LXX, Leviticus 26:43 LXX, Numbers 25:13 LXX, etc.) takes 't as an accusative of limitation (see Joüon, 126g), analogous to how it is used in Exodus 6:3 ("you shall circumcise yourselves in respect of ['t] the flesh of your foreskin"), 1 Kings 15:23 ("he was ill as to ['t] his feet"), and elsewhere. A. S. van der Woude thus translates the Hebrew in his critical commentary as "They shall look on me on account of the one whom they have pierced". The JPS version reads "They shall look unto me because they have thrust him through," the Judaica Press translation reads "They shall look to me because of those who have been thrust through", and the ArtScroll version reads "They will look toward me because of those whom they have stabbed". The text is ambiguous as to whether the figure is an individual or a collective and the use of the singular pronoun in the rest of the verse is not decisive since the singular and plural are both used with collective entities (cf. Hosea 11:1-2). The simplest way of expressing this in English is: "They shall look to me on account of whom they stabbed" (here there is no commital on whether the stabbees are singular or plural).
The text is difficult and there is a good deal of disagreement about which reading best represents what the author intended. But the reference to stabbing (dqr) is likely connected to the war described in the preceding verses. Normally dqr refers to the through-and-through stabbing of a person by a sword or other weapon in battle (Numbers 25:8, Judges 9:54, 1 Samuel 31:4, Isaiah 13:15, Jeremiah 37:10, 51:4, etc.). This is quite different from the poking of Jesus' side with a spear in a non-martial context as described in John 19:17. The passage in Zechariah 12:10 also may have mortal stabbing in battle in view because the very next verse (v. 11) compares the mourning of the pierced to the mourning at Hadad-Rimmon on the plain of Megiddo, likely where Josiah was killed in battle (2 Kings 23:28-30, 2 Chronicles 35:20-27). The link with Josiah suggests that a single kingly, messianic figure may be in view here, as there is indeed such a figure in 9:9-10. Later rabbinical interpretation of the verse took this approach, viewing the Messiah ben Ephraim as the lesser messianic figure who dies in advance of the larger Messiah. But nowhere does the messianic figure of 9:9-10 reappear in the battle described in ch. 12, and there is no mention of such a figure dying, whether in battle (which is wholly inconsistent with v. 8), much less stabbed by his own people. The stabbing is only mentioned obscurely in retrospect. The context imo better supports a reading that interprets the stabbing as pertaining to those killed in battle in v. 6; it would be unusual to mourn for one's enemies which explains why it specifically results from the bestowal of the "spirit of kindness" from God. In support of this reading is the very detailed way in which the mourning is depicted as occurring "clan by clan" within Judah; in v. 12-14, the word mshpchwt "clan" occurs an astonishing 9 times. This emphasis on each and every clan involved in the mourning has its antecedent in v. 6: "When that day comes I will make the clans ('lp, another word for "clan") of Judah like a brazier burning in a pile of wood, like a flaming torch in stubble, and they will consume the peoples round them to right and left". In any case, the verse is open to quite a few different interpretations and in no sense requires the application that John gives to it.