开发者

How to declare Internal table in MySQL?

I want to know how to define or declare Internal table in MySQL

I am new to MySQL and i Don't know the syntax

as you can see I create Stored Procedure

CREATE DEFINER=`root`@`localhost` PROCEDURE `MySP`(
    actioncode VARCHAR(5),
    TNewsID BIGINT
)

BEGIN

IF actioncode = 1 then -- Retrive all from the databas开发者_C百科e --
    select *
    from emp.tbnews;
elseIF actioncode = 2 then -- Retrive all from the database By NewsID --
    select NewsID,NewsSubject,NewsSubjectAR,NewsDetails,NewsDetailsAR,CreatedOn,DisplayOrder,
           AllowDisplay,img  
    from emp.tbnews
    Where NewsID=TNewsID;
elseIF actioncode = 3 then -- fkjskldfjklsdf --
    select NewsID,NewsSubject,NewsSubjectAR,NewsDetails,NewsDetailsAR,CreatedOn,DisplayOrder,
           AllowDisplay,img  
    from emp.tbnews;

 END IF;
 END

What I Really want is to declare Internal table before the IF Statement

in Sql Server I am doing it like this

declare  @tbTemp table (
 a as int,
 b as char...etc.
)

because i want to put insert statement after

IF actioncode = 1
    Insert into @tbTemp

so please if you know tell me how

best regards for every one.


create temporary table tmp
(
id int unsigned not null,
name varchar(32) not null
)
engine=memory; -- change engine type if required e.g myisam/innodb

insert into tmp (id, name) select id, name from foo... ;

-- do more work...

select * from tmp order by id;

drop temporary table if exists tmp;

or

create temporary table tmp engine=memory select id, name from foo... ;

-- do more work...

select * from tmp order by id;

drop temporary table if exists tmp;


Do you mean CREATE TEMPORARY TABLE ? It's an in-memory table specific to the connection running the statement so unless you are running persistent connections you have no worries on name conflicts.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜