首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > 其他数据库 >

select 用法小结

2012-08-22 
select 用法总结1.查看mysql内置函数select now();2.查看存储过程变量select @a;?mysql SELECT Hello W

select 用法总结

1.查看mysql内置函数

select now();

2.查看存储过程变量

select @a;

?

mysql > SELECT 'Hello World' into @x; mysql > SELECT @x; +-------------+ |   @x        | +-------------+ | Hello World | +-------------+ mysql > SET @y='Goodbye Cruel World'; mysql > SELECT @y; +---------------------+ |     @y              | +---------------------+ | Goodbye Cruel World | +---------------------+ mysql > SET @z=1+2+3; mysql > SELECT @z; +------+ | @z   | +------+ |  6   | +------+?

注意:

①用户变量名一般以@开头

②滥用用户变量会导致程序难以理解及管理

?

2.添加标识字段和初值

select 1 flag;


3.通过动态标识来选择

select * from user where true;? 返回所有

select * from user where false; 返回空

实战? 根据用户是否有所有project权限来取出所有project

select * from project where (select is_all_project from user where use_id =13)

热点排行