
(1)查询表中全部信息:
select * from 表名
(2)查询表中指定列的信息:
select 列1,列2 from 表名
(3)去重:
select distinct 列... from 表名
(4)拼接结果:
select concat(列1,列2) from 表名
(5)设置别名(注意:关键字as可以省略)
select 列 as 别名 from 表名
select 列 别名 from 表名
(6)条件查询:
select 列... from 表名 where 条件
条件中比较运算符:(等于:= 大于:> 大于等于:>= 小于:< 小于等于:<= 不等于:!= 或 <>)
(7)where 列 比较运算符 值
注意:字符串、日期需使用单引号括起来
(8)逻辑运算符(并且:and或&& 或:or 非:not或!)
where 条件1 逻辑运算符 条件2
where not 条件
(9)范围查询:
where 列 between 条件1 and 条件2 //列在这个区间的值where 列 not between 条件1 and 条件2 //不在这个区间where !( 列 between 条件1 and 条件2 ) //同样表示不在这个区间
集合查询(判断列的值是否在指定的集合中):
where 列 in(值1,值2) //列中的数据是in后的值里面的where 列 not in(值1,值2) //不是in中指定值的数据
null值查询(注意:列中值为null不能使用=去查询):
where 列 is null //查询列中值为null的数据
资料来源 网页链接
使用游标,需要用存储过程,伪码,另一种就是直接遍历所有记录的,就不写了drop if exist table temp
create table temp
cur = select subject,count(*) as c from t group by where c>1
while cur.next
{
select * from t where subject=cur.subject order by dateline limit cur.c into temp
}
真的那么多的话还是配合view好一点吧,或者使用临时表,in还是不要用了,游标虽然慢,还是可以结束的,in就不行了,找个专门时间有个把小时就行
连接MySQL数据库
在更改就可以了
sql= "update course set courseName =" 'java程序设计'"
提交就行了。
Java的程序自己在Google一下 上面有好多呢。。。。。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)