数据库求码
use
数据库名称(db)
go
--读者表
create
table
zhe
(
id
int
identity(1,1),
numid
varchar(20)
primary
key,
--主键
dname
varchar(20),
post
varchar(20),
dept
varchar(20)
)
--图书表
create
table
books
(
id
int
identity(1,1)
primary
key,
bnum
varchar(20)
foreign
key
references
zhe(numid),
--外键
bname
varchar(20),
bauthor
varchar(20),
bpress
varchar(50),
bprice
decimal,
btype
varchar(10)
)
--借阅记录
create
table
lendrecord
(
id
int
identity(1,1),
lbnum
varchar(20)
foreign
key
references
zhe(numid),
--外键
ldate
datetime,
yhdate
datetime,
redate
datetime
)
Ⅱ VB6.0编程,想把ACCESS07数据库【ABC】中表1中的所有内容都复制到同一数据库的表2里面,求代码。
在工程里引用microsoft activex data objects 2.7 library
Dim cn As New ADODB.Connection, rs1 As New ADODB.Recordset, sql As String '在通用声明里定义,其中cn是连接对象,rs1是记录集,sql是查询语句
Private Sub Form_Load()
cn.Open "provider=microsoft.jet.oledb.4.0;data source=" + App.Path + "\数据库名.mdb" + ""
sql = "select * from 表名"
rs1.Open sql, cn
rs1.MoveFirst
Do While Not rs1.EOF
Combo1.AddItem rs1("字段名")
rs1.MoveNext
Loop
rs1.Close
End Sub
如果你还有什么不懂的,可以网络搜下:编程回忆录,他们现在正在录制这方面的教程,都是零基础开始,由浅入深。
Ⅲ 数据库,求代码
1、 select student.sno,student.sname
from student,sc,course
where student.sno = sc.sno and
sc.cno = course.cno and
course.cname <> '信息系统'
2、 select c1.cno,c1.cname
from course c1,course c2
where c1.cno = c2.cpno and
c1.ccredit = c2.ccredit
3、 select student.sno,student.sname
from student
where not exists
(
select 1
from sc
where grade < 80 and
sc.sno = student.sno
)
4、 select c1.sno,c1.sname
from
(
select student.sno,student.sname
from student,sc,course
where student.sno = sc.sno and
sc.cno = course.cno and
course.cname = '数据库'
)c1,
(
select student.sno,student.sname
from student,sc,course
where student.sno = sc.sno and
sc.cno = course.cno and
course.cname <> '操作系统'
)c2
where c1.sno = c2.sno
5、 select c1.avg,c1.sno,c1.sname
from
(
select avg(sc.grade) avg,student.sno,student.sname
from student,sc,course
where student.sno = sc.sno and
sc.cno = course.cno
group by student.sno,student.sname
)c1
(
select avg(sc.grade) avg
from student,sc,course
where student.sno = sc.sno and
sc.cno = course.cno and
student.sname = '刘晨'
)c2
where c1.avg > c2.avg