# SQL Joins และคิวรีขั้นสูง (Data Science & ML) > INNER JOIN, LEFT/RIGHT JOIN, CROSS JOIN, CTEs, window functions, คิวรีซ้อน, การเพิ่มประสิทธิภาพ - 22 คำถามสัมภาษณ์ - Mid-Level - [คำถามสัมภาษณ์: Data Science & ML](https://sharpskill.dev/th/technologies/data-science/interview-questions.md) ## 1. JOIN ประเภทใดที่คืนค่าเฉพาะแถวที่มีการจับคู่ในทั้งสองตาราง? **คำตอบ** INNER JOIN จะคืนค่าเฉพาะแถวที่มีการจับคู่ในทั้งสองตาราง หากแถวจากตารางด้านซ้ายไม่มีการจับคู่ในตารางด้านขวา (หรือกลับกัน) จะถูกแยกออกจากผลลัพธ์ นี่คือประเภทของ JOIN ที่จำกัดมากที่สุดและใช้บ่อยที่สุดในการรวมข้อมูลที่เกี่ยวข้องกัน ## 2. ผลลัพธ์ของ LEFT JOIN เป็นอย่างไรเมื่อตารางด้านขวาไม่มีการจับคู่? **คำตอบ** LEFT JOIN เก็บแถวทั้งหมดจากตารางด้านซ้ายไว้ แม้ว่าจะไม่มีการจับคู่ในตารางด้านขวา ในกรณีนี้ คอลัมน์จากตารางด้านขวาจะถูกเติมด้วยค่า NULL สิ่งนี้รักษาความสมบูรณ์ของข้อมูลของตารางหลักไว้ในขณะที่เพิ่มข้อมูลทางเลือก ## 3. จะค้นหาลูกค้าที่ไม่เคยสั่งซื้อโดยใช้ JOIN ได้อย่างไร? **คำตอบ** ในการค้นหาเรคคอร์ดที่ไม่มีการจับคู่ ให้ใช้ LEFT JOIN ตามด้วยตัวกรอง WHERE บนคอลัมน์ของตารางด้านขวา IS NULL เทคนิคนี้มีประสิทธิภาพมากกว่าซับคิวรี NOT IN เนื่องจากหลีกเลี่ยงการสแกนตารางคำสั่งซื้อหลายครั้ง นี่คือรูปแบบคลาสสิกสำหรับการตรวจจับข้อมูลกำพร้า ## มีอีก 19 คำถาม - CROSS JOIN ให้ผลลัพธ์อะไร? - SELF JOIN คืออะไรและใช้เมื่อใด? สมัครฟรี: https://sharpskill.dev/th/login ## หัวข้อสัมภาษณ์ Data Science & ML อื่นๆ - [พื้นฐาน Python](https://sharpskill.dev/th/technologies/data-science/interview-questions/python-basics.md): 25 คำถาม, Junior - [การเขียนโปรแกรมเชิงวัตถุด้วย Python](https://sharpskill.dev/th/technologies/data-science/interview-questions/python-oop.md): 20 คำถาม, Junior - [โครงสร้างข้อมูล Python](https://sharpskill.dev/th/technologies/data-science/interview-questions/python-data-structures.md): 20 คำถาม, Junior - [พื้นฐาน Git](https://sharpskill.dev/th/technologies/data-science/interview-questions/git-fundamentals.md): 18 คำถาม, Junior - [พื้นฐาน SQL](https://sharpskill.dev/th/technologies/data-science/interview-questions/sql-basics.md): 20 คำถาม, Junior - [พื้นฐาน NumPy](https://sharpskill.dev/th/technologies/data-science/interview-questions/numpy-fundamentals.md): 22 คำถาม, Junior - [พื้นฐาน Pandas](https://sharpskill.dev/th/technologies/data-science/interview-questions/pandas-basics.md): 22 คำถาม, Junior - [Jupyter & Google Colab](https://sharpskill.dev/th/technologies/data-science/interview-questions/jupyter-colab.md): 16 คำถาม, Junior - [Pandas ขั้นสูง](https://sharpskill.dev/th/technologies/data-science/interview-questions/pandas-advanced.md): 24 คำถาม, Mid-Level - [การแสดงผลข้อมูลด้วย Matplotlib & Seaborn](https://sharpskill.dev/th/technologies/data-science/interview-questions/matplotlib-seaborn.md): 20 คำถาม, Mid-Level - [การแสดงผลแบบโต้ตอบด้วย Plotly](https://sharpskill.dev/th/technologies/data-science/interview-questions/plotly-interactive.md): 18 คำถาม, Mid-Level - [สถิติเชิงพรรณนา](https://sharpskill.dev/th/technologies/data-science/interview-questions/statistics-descriptive.md): 20 คำถาม, Mid-Level - [สถิติเชิงอนุมาน](https://sharpskill.dev/th/technologies/data-science/interview-questions/statistics-inferential.md): 24 คำถาม, Mid-Level - [Web Scraping](https://sharpskill.dev/th/technologies/data-science/interview-questions/web-scraping.md): 18 คำถาม, Mid-Level - [BigQuery & Cloud Data](https://sharpskill.dev/th/technologies/data-science/interview-questions/bigquery-cloud.md): 18 คำถาม, Mid-Level - [Feature Engineering](https://sharpskill.dev/th/technologies/data-science/interview-questions/feature-engineering.md): 22 คำถาม, Mid-Level - [ML แบบมีผู้สอน: การถดถอย](https://sharpskill.dev/th/technologies/data-science/interview-questions/ml-supervised-regression.md): 24 คำถาม, Mid-Level - [ML แบบมีผู้สอน: การจำแนกประเภท](https://sharpskill.dev/th/technologies/data-science/interview-questions/ml-supervised-classification.md): 24 คำถาม, Mid-Level - [Decision Trees และ Ensembles](https://sharpskill.dev/th/technologies/data-science/interview-questions/ml-trees-ensembles.md): 24 คำถาม, Mid-Level - [Unsupervised ML](https://sharpskill.dev/th/technologies/data-science/interview-questions/ml-unsupervised.md): 22 คำถาม, Mid-Level - [ML Pipelines และการตรวจสอบ](https://sharpskill.dev/th/technologies/data-science/interview-questions/ml-pipelines-validation.md): 22 คำถาม, Mid-Level - [Time Series และการพยากรณ์](https://sharpskill.dev/th/technologies/data-science/interview-questions/time-series-forecasting.md): 22 คำถาม, Mid-Level - [พื้นฐาน Deep Learning](https://sharpskill.dev/th/technologies/data-science/interview-questions/deep-learning-fundamentals.md): 24 คำถาม, Senior - [TensorFlow & Keras](https://sharpskill.dev/th/technologies/data-science/interview-questions/tensorflow-keras.md): 22 คำถาม, Senior - [CNN และการจำแนกภาพ](https://sharpskill.dev/th/technologies/data-science/interview-questions/cnn-image-classification.md): 24 คำถาม, Senior - [RNN และซีเควนซ์](https://sharpskill.dev/th/technologies/data-science/interview-questions/rnn-sequences.md): 22 คำถาม, Senior - [Transformers และ Attention](https://sharpskill.dev/th/technologies/data-science/interview-questions/transformers-attention.md): 24 คำถาม, Senior - [NLP และ Hugging Face](https://sharpskill.dev/th/technologies/data-science/interview-questions/nlp-huggingface.md): 24 คำถาม, Senior - [GenAI และ LangChain](https://sharpskill.dev/th/technologies/data-science/interview-questions/genai-langchain.md): 24 คำถาม, Senior - [MLOps และการ Deploy](https://sharpskill.dev/th/technologies/data-science/interview-questions/mlops-deployment.md): 24 คำถาม, Senior --- Source: SharpSkill (https://sharpskill.dev), tech interview preparation for your real stack. HTML version of this page: https://sharpskill.dev/th/technologies/data-science/interview-questions/sql-joins-advanced