当前位置:Gxlcms > 数据库问题 > MySQL-----临时表

MySQL-----临时表

时间:2021-07-01 10:21:17 帮助过:17人阅读

临时表:

  **这是一个表和数据**

  select * from score where num > 60;

  **把这个表的数据变成一个临时的表,作为一个临时的表,那么就可以再对这个临时表中的数据进行查询**

  (select * from score where num >60)as B; 

  这样()中的内容就成了一个临时表的数据,as 后的 B,就是这个临时表的名字。

  **在临时表中再取数据**

  select sid from (select * from score where num>60)as B;

  问题:

    在临时表中取得数据有没有限制。

  答:

    有,只是临时表的有的字段,才可以被二次取值。 例如,表score中有字段sid,student_id,corse_id,number,所以在临时表中可是取出sid字段,如果score中没有sid,是取不出的。

  select number from (select corse_id,number from score where num>60)as B;

  

  

MySQL-----临时表

标签:--   rom   取得数据   取数   sql   一个   sel   number   _id   

人气教程排行