|
|
|
สร้าง Temporary Table จาก phpMysql มีตัวอย่างไหมครับ |
|
|
|
|
|
|
|
จะต้องใช้บน Stored Procedure ครับ
Code (SQL)
DROP PROCEDURE IF EXISTS getCustomer;
DELIMITER //
CREATE PROCEDURE getCustomer()
BEGIN
# Create Temp Table
CREATE TEMPORARY TABLE IF NOT EXISTS temp(
RowID INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
Name VARCHAR(50),
CountryName VARCHAR(50)) ENGINE = MEMORY;
# Insert Table
INSERT INTO temp (Name,CountryName) VALUES ('Weerachai Nukitram','Thailand');
INSERT INTO temp (Name,CountryName) VALUES ('Surachai Sirisart','United Stats');
INSERT INTO temp (Name,CountryName) VALUES ('Adisorn Boonsong','United Kingdom');
# Return Rows
SELECT * FROM temp;
# Drop Table
DROP TABLE temp;
END //
DELIMITER ;
การสร้าง Declare Temp Table - TEMPORARY (MySQL : Stored Procedure)
|
|
|
|
|
Date :
2016-08-05 13:07:58 |
By :
mr.win |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|