I'm not even sure how to ask this question, so please bear with me. Due to the database structure, I need to run a small sql script for efficiency's sake. If I do everything in one query it takes forever. If I do it in a script, it takes 5 secs. I have the script working in the MySQL query browser and it uses temporary tables, so all this has to be done on one connect to the server. Here is the mysql script that I want to run....
drop temporary table if exists skfgreconcile1;
CREATE TABLE `pointofuse`.`skfgreconcile1` (
`Lot` VARCHAR(10) NOT NULL DEFAULT '',
`CustomerPartNumber` VARCHAR(45) NOT NULL DEFAULT '',
`CustomerPartNumberRevision` VARCHAR(45) NOT NULL DEFAULT '',
`PiecesUsed` INTEGER UNSIGNED NOT NULL DEFAULT 0,
`PiecesRemaining` INTEGER UNSIGNED NOT NULL DEFAULT 0,
`WorkOrder` VARCHAR(45) NOT NULL DEFAULT '',
INDEX `Index_1`(`Lot`)
)
ENGINE = memory;
insert into skfgreconcile1
(lot, customerpartnumber, customerpartnumberrevision,workorder,piecesused)
select lot, customerpartnumber, customerpartnumberrevision, workorder, sum(qty)
from transhist
where workorder='M833Z00'
group by lot, customerpartnumber, customerpartnumberrevision, workorder
;
drop temporary table if exists skfgreconcile2;
CREATE TABLE `pointofuse`.`skfgreconcile2` (
`Lot` VARCHAR(10) NOT NULL DEFAULT '',
`PiecesRemaining` INTEGER UNSIGNED NOT NULL DEFAULT 0,
INDEX `Index_1`(`Lot`)
)
ENGINE = memory;
insert into skfgreconcile2
(lot, piecesremaining)
select i.lot, sum(i.pieces)
from customerinventory i, skfgreconcile1 r
where i.lot=r.lot
group by i.lot
;
update skfgreconcile1, skfgreconcile2
set skfgreconcile1.piecesremaining = skfgreconcile2.piecesremaining
where skfgreconcile1.lot=skfgreconcile2.lot;
What I need to display on the php page after the above sql runs is basically
select * from skfgreconcile1;
I know how to display the results from the single select * from skfgreconile1, but have no idea how to run the preceeding script so I can do the simple select. I don't even know what function in php to use to do this. Just put everything in one big honking $query line and then just do a normal mysql_query($query)? Any suggestions?
Thanks
TD