两条SQL

今天做项目,,在SQL审查的时候,有点感慨。贴:

        insert into book_readstat_day(bid,read_date,read_count,created,updated,book_display_id,book_g_display_id,ttype)
        values (#bid#, #readDate#, #readCount#,now(),now(),(select display_id from book_book where id=#bid#),(select fid from book_display where id=(select display_id from book_book where id=#bid#)),#ttype#)

 

改成了:

INSERT INTO book_readstat_day(bid,read_date,read_count,created,updated,book_display_id,book_g_display_id,ttype)
SELECT 67, '2010-01-06', '42',NOW(),NOW(),a.display_id, b.fid,1 FROM book_book a JOIN book_display b ON a.display_id = b.id WHERE a.id ='67';

 

学习吧!。。。

你可能感兴趣的:(数据库,(Oracle,Sql,Server,My,SQl)