081219--取公有部分select * from t_Goods a inner join t_Storein b on a.gid=b.gid--右邊的表全部取,左邊表取相匹配的select * from t_Goods a right join t_Storein b on a.gid=b.gid--左邊表全部取,右邊表取相匹配的select * from t_Goods a left join t_Storein b on a.gid=b.gid 例表a aid adate 1 a1
081223模糊查詢,分詞查詢,論壇討論地址:http://topic.csdn.net/u/20081223/14/bafce97c-3c2f-4c50-bd62-a4dc176c3506.html?seed=75962426use lyds#dbselect * from t_Goods wheresummary like '%桌%' and summary like '%老%'select * space(20) as 空格 from
exists和no existshttp://hi.baidu.com/yds_amber/blog/item/0f64cfcf2c91b13bf8dc61d2.htmlSELECT * FROM a left join b on a.id=b.id2 where not exists (select 1 from b b1 where b.id2 = b1.id2 and b.xh > b1.xh)就是不在這個範圍的意思 select id from table where
應用一:--use lyds#db--select id,count(test) from t_test group by id --這是分組的效果--資料表id(int) test(nvarchar(50)) 1 aaa 2 bbb 1 ccc 2 ddd--建立自訂函數CREATE FUNCTION dbo.f_str(@id int)RETURNS varchar(8000)ASBEGIN DECLAR
今天寫了個複雜的sql語句,結果證明不符合項目要求,但是文法值得學習,記下來。declare @delId int --要刪除的行declare @cid intset @delId='001002'begin transaction t1delete from ttest where 單位編號=@delId declare mycur cursor for select id from ttest where convert(int,單位編號)>convert(int,@delI
預存程序CREATE PROCEDURE [dbo].[Login_Test] ( @UserName nvarchar(50), @flag int out)AS if exists(SELECT * FROM Admin WHERE UserName =@UserName) begin set @flag=11; end else begin set @flag=10; endGO執行方法/// <summa