Internship, Day 29 (30 May 2012)
Posted on May 31st, 2012 in computer, in English, in Thai, personal, programming, SQL | No Comments »

(Photo: More “proper food” my friend eats.)
ใกล้ครบกำหนดฝึกงานขั้นต่ำแล้ว (ของผมต้องถึง Day 32 เพราะลางานไป 10 ชั่วโมง) วันนี้ผมไปทำงานโดยมีเจตนาเอาฐานข้อมูลที่มีอยู่แล้วมาใช้ล้วนๆ เลย สำหรับงานที่ได้ในตอนนี้คือทำให้ระบบบันทึกการใช้งาน IDC บันทึกการนำอุปกรณ์เข้าและออกได้สมบูรณ์แล้ว แต่ยังไม่สามารถยกเลิกงานบางส่วนระหว่างทำงานได้ในบางกรณี (การยกเลิกงานอาจเกิดขึ้นในกรณีที่ไม่ต้องการทำงานนั้นๆ อีกต่อไป เช่น ตรวจพบทีหลังว่าเซิร์ฟเวอร์ที่นำมาใช้ไม่ได้ หรือไม่ต้องการนำของออกแล้ว เป็นต้น) เนื่องจากยังติดปัญหาว่าโค้ดเก่าพึ่งพา PHP Session มากเกินไป แต่กลับไม่ยอมเก็บตัวแปรที่อ้างถึงผู้ใช้ไว้เลย
So I’m nearing the minimum hours for internship (actually I need 32 days because I took 10 hours of leave). Today I came to work with pure intention to utilize the old database. Today I got the IDC visitor system working right with equipment installation and returns, but still cannot cancel jobs half-way in some cases (It might occur due to server installation error, or customer no longer wishes to remove the piece, for example.) owing to the dependency of the old code on PHP Session system, but lack of any actual reference to database.
Delete from multiple tables
DELETE table1, table2 FROM table1, table2 WHERE table1.pk = table2.pk AND (your_condition_here);
Select neighbors
If you have some tuple (x1,y) where you know only the value of x1, and you wish to select (x1,y), (x2,y), …, (xn,y), this is way to go.
SELECT X AS REFX, Y AS REFY
FROM your_table
WHERE EXISTS
(
SELECT * FROM your_table
WHERE Y = REFY
AND X = $x1
)




