]]>哎~Q可怕的今天Q?/title>http://www.aygfsteel.com/tonylovexl/archive/2006/11/07/79700.htmll雨渔Rl雨渔RTue, 07 Nov 2006 13:50:00 GMThttp://www.aygfsteel.com/tonylovexl/archive/2006/11/07/79700.htmlhttp://www.aygfsteel.com/tonylovexl/comments/79700.htmlhttp://www.aygfsteel.com/tonylovexl/archive/2006/11/07/79700.html#Feedback0http://www.aygfsteel.com/tonylovexl/comments/commentRss/79700.htmlhttp://www.aygfsteel.com/tonylovexl/services/trackbacks/79700.html 今天在深入学习了数据库方面的知识。感觉挺吃力?今天发现很多理论的知识掌握很不牢固,真是很惭愧,今后q得l箋在理Z下工夫。再说今天接触的知识吧,今天老L入讲解了关于select查询Ҏ的用,发现q个东西实在是太灉|了!目前的自己拿着一个小目也无法找C手的方向Q这应该是极度~Zl验的表玎ͼ今后q得多多l习才能有显著的提高。关于selectQ我先是很无语,实是非常的灉|Q就其中的连接一,呛得我要死Q看来自己在q几天还得多多看相关的资料多多做l习才行。希望在研究数据库的同志们也加aQ多看书Q多看看好的代码Q多ȝ解,q样自己才能有提高?最后,把今天在老d领下完成的关于电子书店数据库pȝ的代码放在这里,对于老手来说非常的简单,望所有新手共勉!
Q该代码没有涉及insert intoQ其中数据可以根据实际情冉|加)
create table customers (customerID int primary key not null, customername varchar(20) not null);
create table books (bookid int primary key not null, booktitle varchar(50) not null, unitprice int not null );
create table orders (orderid int primary key not null, orderdate date default sysdate not null, customerid int not null, constraint fk_c foreign key (customerid) references customers(customerid) );
create table orderitems (OrderItemID int primary key not null, orderid int not null, bookid int not null, quantity int default '1' not null, constraint fk_b foreign key (bookid) references books(bookid), constraint fk_o foreign key (orderid) references orders(orderid));
select c.customername as 客户名称, sum(b.unitprice * oi.quantity) from customers c left join orders o on c.customerid = o.customerid left join orderitems oi on o.orderid = oi.orderid left join books b on oi.bookid = b.bookid where to_char(o.orderdate,'yyyy') = to_char(sysdate,'yyyy') group by c.customername