One should be precise regarding the wording of our teacher, the Beit Yosef, who wrote: "it is as if he did not eat in the sukkah." But according to Torah law, he certainly fulfilled his obligation, since it is only due to a decree lest he be drawn after his table! And indeed, the wording of the Rambam who wrote: "One whose head and most of his body were in the sukkah, and his table was outside the sukkah, and he eats – behold, this is forbidden, and it is as if he did not eat in the sukkah... a decree etc." Thus far his words. And he elaborated intentionally, and this is the explanation: Behold, this is forbidden by rabbinic law, and they were stringent upon him as if he did not eat in the sukkah. But according to Torah law – he certainly fulfilled his obligation. However, our teacher, the Beit Yosef, who wrote explicitly "it is as if he did not eat in the sukkah" – it implies that even according to the Torah it is so, and this is impossible. And it appears that the matter is as follows: That certainly it is only rabbinic, but the sages established it such that even according to the Torah he does not fulfill his obligation, because the ruin is near. And they were compelled to this from the wording of the Mishnah (28a), as they said regarding this that one who does so – has never fulfilled the mitzvah of sukkah in his days. And this is what the Rambam says: "Behold, this is forbidden." Meaning: by rabbinic law, and they made it as if he did not eat according to the Torah. And our teacher, the Beit Yosef, also intended this, but he was brief in his words (and so wrote the Tosafot in Berakhot 11a and at the beginning of Sukkah). And if part of the table stands in the sukkah, and part of it is outside the sukkah – it is permitted (Magen Avraham).
ויש לדקדק בלשון רבינו הבית יוסף, שכתב: כאלו לא אכל בסוכה. והא מדאורייתא וודאי יצא, כיון שאינו אלא משום גזירה שמא ימשך אחר שולחנו!ובאמת לשון הרמב"ם שכתב: מי שהיה ראשו ורובו בסוכה, ושולחנו חוץ לסוכה, ואוכל – הרי זה אסור, וכאלו לא אכל בסוכה… גזירה וכו'. עד כאן לשונו. והאריך בכוונה, והכי פירושו: הרי זה אסור מדרבנן, והחמירו עליו כאלו לא אכל בסוכה. אבל מדאורייתא – וודאי יצא. אבל רבינו הבית יוסף שכתב להדיא "כאלו לא אכל בסוכה" – משמע דגם מן התורה כן, וזה אי אפשר. ונראה דהעניין כן הוא: דוודאי אינו אלא דרבנן, אך רבנן עשאוהו שגם מן התורה אינו יוצא, מפני שהקלקול קרוב. והוכרחו לזה מלשון המשנה (כח א), שאמרו על זה שהעושה כן – לא קיים מצות סוכה מימיו. וזהו שאומר הרמב"ם: הרי זה אסור. כלומר: מדרבנן, ועשאוהו כאלו לא אכל מן התורה. ורבינו הבית יוסף גם כן כוונתו כן, אלא שקיצר בדבריו (וכן כתב התוספות בברכות יא א ובריש סוכה). ואם מקצת השולחן עומד בסוכה, ומקצתו חוץ לסוכה – מותר (מגן אברהם).