วันจันทร์ที่ 25 มกราคม พ.ศ. 2559

DBMS

DBMS

     MySQL

   เหตูผลที่เลือก MySQL เพราะเป็น FREE Software และมีคนใช้ทั่วโลก และรองรับ tool ของหลายๆ Program



รูปที่ 1 เป็นการสร้าง table 

SQL DELETE Statement

SQL DELETE Statement


    DELETE เป็นคำสั่งที่ใช้ลบ records จาก table


Syntax



รูปที่ 1 เป็น Syntax ในการใช้คำสั่ง DELETE

ตัวอย่างการใช้งาน


รูปที่ 2 เป็นการลบ records Customers ของ Alfreds Futterkiste และ Maria Anders

by  http://www.w3schools.com/sql/sql_delete.asp

The SQL UPDATE Statement

The SQL UPDATE Statement


    UPDATE เป็นคำสั่งที่ใช้อัพเดท records ใน table

Syntax


รูปที่ 1 เป็น Syntax ในการใช้คำสั่ง UPDATE

ตัวอย่างการใช้



รูปที่ 2 เป็นการอัพเดท records ใน table

by  http://www.w3schools.com/sql/sql_update.asp

SQL INSERT INTO Statement

SQL INSERT INTO Statement


    INSERT INTO  เป็นคำสั่งที่ใช้เพิ่ม records ลงไปใน table

Syntax


รูปที่ 1 เป็น Syntax ในการใช้ INSERT INTO

ตัวอย่างการใช้งาน


รูปที่ 2 เป็นการเพิ่ม records ลงใน table

by  http://www.w3schools.com/sql/sql_insert.asp


SQL ORDER BY Keyword

SQL ORDER BY Keyword

    ORDER BY เป็นคำสั่งที่ใช้เรียงข้อมูล หรือ row โดยจะยึด column ที่เลือก และสามรถเลือกได้ว่าจะเรียงแบบไหน

Syntax


รูปที่ 1 เป็น Syntax ที่ใช้คำสั่ง ORDER BY

ตัวอย่างการใช้


รูปที่ 2 เป็นการเรียงข้อมูลจาก A-Z โดยใช้ column Country เป็นหลัก

by  http://www.w3schools.com/sql/sql_orderby.asp

The SQL AND & OR Operators

SQL AND & OR Operators


    AND & OR เป็นคำสั่งที่ใช้ควบคู่กับ WHERE เพื่อเพิ่มเงือนไขในการเลือก

ตัวอย่งการใช้งาน


รูปที่ 1 การใช้ AND


รูปที่ 2 การใช้ OR


รูปที่ 3 การใช้ AND & OR

by  http://www.w3schools.com/sql/sql_and_or.asp


SQL WHERE Clause

SQL WHERE Clause

    WHERE  เป็นคำสั่งที่ใช้ในการเลือกเฉพาะข้อมูลใน column ที่ต้องการจาก table 

Syntax



รูปที่ 1 เป็น Syntax ในการใช้คำสั่ง WHERE

ตัวอย่างการใช้งาน



รูปที่ 2 เป็นการเรียก column Country ที่ข้อมูลใน row เป็น Mexico จาก table Customers


by  http://www.w3schools.com/sql/sql_where.asp

SQL SELECT DISTINCT

SQL SELECT DISTINCT

    SELECT DISTINCT  เป็นคำสั่งที่ใช้เรียก column จาก table โดยค่าใน row ต้องไม่ซ้ำกัน ซึ่งจะต่างจาก SELECT ตรงที่ SELECT จะเลืกทั้งหมดใน column นั้นโดยไม่สนใจว่าจะซ้ำกันหรือไม่

syntax


รูปที่ 1 เป็น Syntax ของ SELECT DISTINCT

ตัวอย่างการใช้งาน



รูปที่ 2 เป็นการเรียก column Country ที่ไม่ซ้ำกัน จาก table Customers

by  http://www.w3schools.com/sql/sql_distinct.asp

SQL SELECT

SQL SELECT

   SELECT  เป็นคำสั่งที่ใช้ในการเรียกดูตารางที่ต้องการจากฐานข้อมูล

Syntax


รูปที่ 1  เป็น syntax ในการใช้คำสั่ง SELECT

ตัวอย่างการใช้


รูปที่ 2 เป็นการเรียก column CustomerName,City จาก table Customers


รูปที่ 3 เป็นการเรียก table Customers ทั้งหมด


by  http://www.w3schools.com/sql/sql_select.asp


SQL Tutorial

SQL Tutorial

    SQL is a standard language for accessing databases.
    Our SQL tutorial will teach you how to use SQL to access and manipulate data in: MySQL, SQL Server, Access, Oracle, Sybase, DB2, and other database systems.


รูปที่ 1 เป็นตัวอย่างคำสั่งของ SQL ที่ใช้ในการเลือกตารางที่ต้องการ

by  http://www.w3schools.com/sql/default.asp

วันอังคารที่ 19 มกราคม พ.ศ. 2559

Home Work (Week 1)



คำถาม

- Can we calcuate average GPA of all students?


- Can we calcuate average grade of a subject?

ตอบ ต้องทำ table เป็นรูปแบบเดียวกันแล้วดึงจากตำแหน่งเดียวกันแล้วนำมาคำนวณ