有个表的数据结构是这样的,
日期 小时 值
现在要查询数据结果,要按日期排序,在1行中按1-24列值的数据,SQL语句该怎么写?
举例:
原表
日期 时间 VALUE
01 1 1
01 2 2
02 3 3
02 4 4
生产的新表要求:
日期 时1 时2 时3 时4 。。。时24
01 1 2
02 3 4
无 ......
create table test(t_a int,t_b int,t_c datetime)
insert into test(t_a,t_b)values (1,1,'2000-01-01')
insert into test(t_a,t_b)values (1,2,'2000-02-01')
insert into test(t_a,t_b)values (1,3,'2000-03-01')
insert into test(t_a,t_b)values (2,1,'2000-04-01')
insert into test(t_a,t_b)values (2,1,'2000- ......
album:
id p_id title
1 0 类别一
2 1 类别的子类
3 0 类别三
4 3 类别三的子类
album_photo:
id albumid(对应上面的id) title
1 3 文章一
2 4 文章2
现在需要做一个 删除 类别的操作, 当删除album 一个类别的时候 , 检查它是否有 ......
编写SQL脚本,可以遍历Test数据库的所有数据表,针对各表的所有数据记录,分析出内容为NULL的字段
楼主,这有何必呢?
程序的输出函数兼容Null就可以了。。。。。
把 Test数据库的所有数据表表名插入到一个临时表中,然后再循环遍历该临时表进行相关操作...
楼上的,我是用你说的方法,是找的资料,但是提示'mast ......
A表
AID A_col1 A_col2 A_col3
1 200 a12 a13
2 200 a22 a23
3 200 a32 a33
4 201 a42 a43
5 201 a52 a53
6 201 a62 a63
B表
BID B_col1 B_col2 B_col3
1 200 1,2 b13
2 200 3 b23
3 201 4,5,6 b33
表的关系:
B_Co ......
要插入一个值,但是条件在另外一个表请问怎么写SQL 啊?
我是这样写的
SQL code:
insert into A(xc) values('123')select name from B where name='张三'
肯定不对
我想 把一个值插入A表的 xc字段,条件是B表 名字为张三 才可以
请问怎么写啊?
SQL code:
insert A(XC) SELECT 字段 from B where name='张三'
......