1. คำสั่งสร้างตาราง CREATE พิเศษกว่าตาราง ธรรมดา คือ มีการระบุคำว่า TEMPORARY เข้าไปด้วยนั้นเอง
โค้ด: เลือกทั้งหมด
$sql = 'CREATE TEMPORARY TABLE tmp_topic_id ( topic_id_tmp INT NOT NULL );';
$result = $this->db->sql_query($sql);
2. ตัวอย่างคำสั่ง Insert
โค้ด: เลือกทั้งหมด
$sql = 'INSERT INTO tmp_topic_id (topic_id_tmp) VALUES (1)';
$result = $this->db->sql_query($sql);
โค้ด: เลือกทั้งหมด
$sql = 'SELECT * FROM tmp_topic_id';
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result)) {
$topic_id_tmp[] = $row['topic_id_tmp'];
}
SQL SELECT SUBQUERY ดูได้จากตัวอย่างนี้ค่ะ ==> การ SELECT ข้อมูลด้วย SELECT ซ้อน SELECT
https://www.mindphp.com/forums/viewtopic.php?t=18637