`

select 1 from table 含义

阅读更多
1. select  1 from ..., sql语句中的1代表什么意思?查出来是个什么结果?

   select 1 from table;与select anycol(目的表集合中的任意一行) from table;与select * from table 从作用上来说是没有差别的,都是查看是否有记录,一般是作条件查询用的。select 1 from 中的1是一常量(可以为任意数值),查到的所有行的值都是它,但从效率上来说,1>anycol>*,因为不用查字典表。

2. table表是一个数据表,假设表的行数为10行。

A:select  1 from table  增加临时列,每行的列值是写在select后的数,这条sql语句中是1

B:select count(1) from table 不管count(a)的a值如何变化,得出的值总是table表的行数

C:select sum(1) from table 计算临时列的和

3. 语句
  if not exists(select 1 from table)验证table表是否存在记录信息。
分享到:
评论

相关推荐

    mysql SELECT 列 FROM 表 WHERE 条件 选择:select * from table where 范围

    SELECT 列 FROM 表 WHERE 条件 选择:select * from table where 范围 ...查找:select * from table where field1 like ’%value1%’ 6 排序:select * from table order by field1,field2 [desc]

    sqlserver数据库常用语句基本涵盖日常所需,带中文解释说明

    选择:select * from table1 where 范围 插入:insert into table1(field1,field2) values(value1,value2) 删除:delete from table1 where 范围 更新:update table1 set field1=value1 where 范围 查找:select * ...

    SQL 2008 常用语句大全

     选择:select * from table1 where 范围  插入:insert into table1(field1,field2) values(value1,value2)  删除:delete from table1 where 范围  更新:update table1 set field1=value1 where 范围  ...

    INSERT INTO SELECT语句与SELECT INTO FROM语句的一些区别

    1.INSERT INTO SELECT语句 语句形式为:Insert into Table2(field1,field2,…) select value1,value2,… from Table1 要求目标表Table2必须存在,由于目标表Table2已经存在,所以我们除了插入源表Table1的字段外,还...

    SQLite3 轻量级数据库及SQL语法指导

    排序:select 字段 from table1 order by 字段(desc或asc) ;(降序或升序) 分组:select 字段 from table1 group by 字段,字段… ; 限制输出:select 字段 from table1 limit x offset y; = select?字段?from?table1 ...

    UCenter info: MySQL Query Error SQL:SELECT value FROM [Table]vars WHERE noteexists

    SQL:SELECT value FROM [Table]vars WHERE name=’noteexists2′ UCenter info: MySQL Query Error SQL:SELECT value FROM [Table]vars WHERE name=’noteexists2′ Error:SELECT command denied to user ‘数据库...

    SQL语句经典大全

    选择:select * from table1 where 范围 插入:insert into table1(field1,field2) values(value1,value2) 删除:delete from table1 where 范围 更新:update table1 set field1=value1 where 范围 查找:...

    数据库基础知识考试及答案.doc

    查找:select * from table1 where field1 like ’%value1%’ (所有包含‘value1’这个模式的字符串) 排序:select * from table1 order by field1,field2 [desc] 求和:select sum(field1) as sumvalue from ...

    经典sql语句大全 sql语句

    选择:select * from table1 where 范围 插入:insert into table1(field1,field2) values(value1,value2) 删除:delete from table1 where 范围 更新:update table1 set field1=value1 where 范围 查找:select * ...

    Oracle中的select into

    select valueA,valueB into tableB from tableA; 上面这句语句的意思是将tableA表中的valueA和valueB字段的值和结构添加到tableB中,tableB表需不存在。 在Oracle中select into的等价用法 create table tableB as ...

    mysql 常用语句+实例

    选择:select * from table1 where 范围 插入:insert into table1(field1,field2) values(value1,value2) 删除:delete from table1 where 范围 更新:update table1 set field1=value1 where 范围 查找:select * ...

    华为公司 java 面试题

    ......... SELECT * FROM TABLE WHERE NAME LIKE '%%' AND ADDR LIKE '%%' AND (1_ADDR LIKE '%%' OR 2_ADDR LIKE '%%' OR 3_ADDR LIKE '%%' OR 4_ADDR LIKE '%%' ) ...........

    110道 MySQL面试题及答案

    答案:使用SELECT语句并列出所需的列名,例如:SELECT column1, column2 FROM table_name; 1. 如何根据条件查询记录? 答案:使用SELECT语句并在WHERE子句中指定条件,例如:SELECT * FROM table_name WHERE ...

    数据库SQL查询语句练习题.doc

    查找:select * from table1 where field1 like ’%value1%’ (所有包含‘value1’这个模式的字符串) 排序:select * from table1 order by field1,field2 [desc] 求和:select sum(field1) as sumvalue from ...

    select into 和 insert into select 两种表复制语句

    第一句:SELECT * INTO [ToTable] FROM [FromTable] 第二句:INSERT INTO [ToTable] ([fild_One],[fild_Two]) SELECT [fild_One], 8 FROM [FromTable] 以上两句都是将 [FromTable] 的数据插入到 [ToTable],但两句...

    PHP100视频教程 13:PHP+MYSQL分页原理

    1、SQL语句中的limit用法SELECT * FROM table …… limit 开始位置 , 操作条数2、学习分页的一种公式(1)分页原理所谓分页显示,也就是讲数据库中的结果集,一段一段显示出来(2)需要的条件怎么分段,当前在第几...

    SQL语句大全(经典珍藏版)

    查找:select * from table1 where field1 like ’%value1%’ ---like的语法很精妙,查资料! 排序:select * from table1 order by field1,field2 [desc] 总数:select count as totalcount from table1 求和:...

    经典Sql语句 数据库

    经典Sql语句 一、基础 1、说明:创建数据库 CREATE DATABASE database-name 2、说明:删除数据库 drop database dbname 3、说明:备份sql server ...最小:select min(field1) as minvalue from table1

    SQL操作全集(非常适合初学者)

    查找:select * from table1 where field1 like ’%value1%’ ---like的语法很精妙,查资料! 排序:select * from table1 order by field1,field2 [desc] 总数:select count * as totalcount from table1 求和:...

    某知名公司内部ORACLE培训资料(如果你看后觉得不行,可以损我,人格担保)

    查找:select * from table1 where field1 like ’%value1%’ ---like的语法很精妙,查资料! 排序:select * from table1 order by field1,field2 [desc] 总数:select count as totalcount from table1 求和:...

Global site tag (gtag.js) - Google Analytics