ตอบ SELECT studentid,name,advisor,class,hobby
FROM student
WHERE hobby like 'อ่านหนังสือ';
ได้ภาพต่อไปนี้
►คำอธิบาย โดยเลือกที่จะให้แสดงชั้นข้อมูล รหัสนิสิต ชื่อ-สกุล อาจารย์ที่ปรึกษา ชั้นปี งานอดิเรก จากตารางนักเรียน (student) มีเงื่อนไขคือ ชั้นข้อมูลของงานอดิเรกต้องมีคำว่า อ่านหนังสือ
✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿
I. ให้นิสิตสืบค้นข้อมูลด้วยภาษา SQL ตามคำถาม "ให้เลือกฟิลด์ทั้งหมดจากตารางรายวิชา (subject)"
ตอบ SELECT subjectid,name,credit,book,teacher
FROM subject ;
จะได้ภาพดังนี้
✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿
J. ให้นิสิตสืบค้นข้อมูลด้วยภาษา SQL ตามคำถาม "ให้เลือกฟิลด์รหัสรายวิชา ชื่อรายวิชา และจำนวนหน่วยกิต จากตารางรายวิชา (subject)"
ตอบ SELECT subjectid,name,credit
FROM subject;
ได้ภาพดังต่อไปนี้
✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿
K. ให้นิสิตสืบค้นข้อมูลด้วยภาษา SQL ตามคำถาม "ให้เลือกฟิลด์รหัสรายวิชา ชื่อรายวิชา และจำนวนหน่วยกิต จากตารางรายวิชา (subject) โดยมีเงื่อนไขคือเป็นรายวิชา 104111"
ตอบ SELECT subjectid,name,credit
FROM subject
WHERE subjectid = 104111 ;
จะได้ภาพดังนี้
✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿
L. ทดลองพิมพ์ SELECT student.studentid,student.name,register.score,register.grade FROM register,student WHERE (register.studentid = student.studentid AND register.studentid = 4902) แล้วเลือก Run Query แล้วสังเกตผลที่ได้รับ
ตอบ SELECT student.studentid,student.name,register.score,register.grade
FROM register,student
WHERE (register.studentid = student.studentid AND register.studentid = 4902);
จะได้ภาพดังนี้
►คำอธิบาย จากที่มีการกำหนดเงื่อนไขเป็นรหัสนิสิต 4902 ที่มีในตาราง student และ ตาราง register เกิดการ join ตารางกันจะแสดงให้เห็นถึง ชื่อ คะแนน เกรดของนิสิตรหัส 4902
✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿
M. ทดลองปรับเป็น SELECT student.studentid,student.name,register.score,register.grade,subject.name FROM register,student,subject WHERE (register.studentid = student.studentid AND register.studentid = 4902) AND (register.subjectid=subject.subjectid)
ตอบ SELECT student.studentid,student.name,register.score,register.grade,subject.name
FROM register,student,subject
WHERE (register.studentid = student.studentid AND register.studentid = 4902) AND (register.subjectid=subject.subjectid);
จะได้ภาพดังนี้
►คำอธิบาย จากการกำหนดเงื่อนไขจากตาราง 3 ตารางได้แก่ student,register และ subject ที่มี studentid โดยเกิดจากการ join ตารางสามตาราง
✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿
N. ทดลองปรับเป็น SELECT student.studentid,student.name,register.score,
register.grade,subject.name FROM register,student,subject WHERE (register.studentid = student.studentid) AND (register.subjectid = subject.subjectid AND register.subject = 104111) สังเกตผลที่ได้รับ
register.grade,subject.name FROM register,student,subject WHERE (register.studentid = student.studentid) AND (register.subjectid = subject.subjectid AND register.subject = 104111) สังเกตผลที่ได้รับ
ตอบ SELECT student.studentid,student.name,register.score,register.grade,subject.name
FROM register,student,subject
WHERE (register.studentid = student.studentid) AND (register.subjectid = subject.subjectid AND register.subjectid = 104111);
จะได้ภาพดังนี้
►คำอธิบาย จากเงื่อนไขที่ทำให้เกิดการ join ตารางกัน 2 ตาราง โดยเลือกใช้ฟิลด์ studentid และ subjectid จากตาราง student และ subject
✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿
O. จากข้อ m เมื่อแปลออกมาเป็นภาษาคำถามของมนุษย์จะได้ว่า "ให้เลือกแสดงฟิลด์รหัสนิสิต ชื่อนิสิต คะแนน เกรด และชื่อรายวิชา จากตารางนักเรียน (student) การลงทะเบียน (register) และรายวิชา (subject) โดยมีเงื่อนไข คือแสดงเฉพาะนิสิตรหัส 4902 เท่านั้น" ให้ลองแปลข้อ n ออกมาเป็นภาษาคำถามของมนุษย์
ตอบ ทำการเลือกแสดงฟิลด์รหัสนิสิต ชื่อนิสิต คะแนน เกรด และรายชื่อวิชา จากตาราง student register และ subject โดยมีเงื่อนไข คือ แสดงรหัสนิสิต 4902 เท่านั้น
SELECT student.studentid,student.name,register.score,register.grade,subject.name
FROM register,student,subject
WHERE (register.studentid = student.studentid) AND (register.subjectid = subject.subjectid AND register.studentid = 4902);
✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿
P. ให้นิสิตสืบค้นข้อมูลด้วยภาษา SQL ตามคำถาม "ให้เลือกแสดงฟิลด์รหัสนิสิต ชื่อนิสิต คะแนน เกรด และชื่อรายวิชา จากตารางนักเรียน (Student) ตารางการลงทะเบียน (Register) และรายวิชา (Subject) โดยมีเงื่อนไขคือแสดงเฉพาะรายวิชารหัส 104111 เท่านั้น และนิสิตอยู่ในชมรมภูมิศาสตร์เท่านั้น"
ตอบ SELECT student.studentid,student.name,register.score,register.grade,subject.name,student.club
FROM register,student,subject
WHERE (register.studentid = student.studentid AND register.subjectid = subject.subjectid) AND register.subjectid = 104111 AND student.club = 'ภูมิศาสตร์';
ได้ภาพดังนี้
✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿*゚’゚・.。*✿







