CREATE TABLE - SELECT (MySQL)

Uit De Vliegende Brigade
Naar navigatie springen Naar zoeken springen
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Aanmaken van een tabel die gevuld moet worden met data uit een andere tabel, kan efficiënt gecombineerd worden, waarbij je die nieuwe tabel niet expliciet hoeft te defineren. Voorbeeld:

create table tbl_doel select * from tbl_bron where id>99;

Voorbeeld met een complete query als input:

-- Dit is de select-query

select rootm2.sku from rootm2
left join ean_code
on rootm2.sku = ean_code.sku
where ean_code.sku is null;

drop table if exists tmp;
create table tmp

        -- Dit is opnieuw de select-query, zonder wijzigingen
        --
	select rootm2.sku from rootm2
	left join ean_code
	on rootm2.sku = ean_code.sku
	where ean_code.sku is null

Zie ook