Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

sql´æ´¢¹ý³Ìʱ¼äÏà¼õ - MS-SQL Server / »ù´¡Àà

CREATE PROCEDURE [selectvipcompany] 
@username varchar(50),
@companyname varchar(50),
@endtime varchar(1)
AS
declare @sql varchar(1000)
set @sql=''
if (@username<>null and @username<>'' )
  set @sql=@sql+'username like '+char(39)+'%'+@username+'%'+char(39)
if (@companyname<>null and @companyname<>'' and @sql<>'')
  set @sql=@sql+' and companyname like '+char(39)+'%'+@companyname+'%'+char(39)
else if (@companyname<>null and @companyname<>'' and @sql='')
  set @sql=@sql+'companyname like'+char(39)+' %'+@companyname+'%'+char(39)
if (@endtime='1' and @sql<>'')
  set @sql=@sql+' and '+datediff+char(40)+'endviptime,'+getDate()+char(41)+'<0'
else if(@endtime='1' and @sql='')
  set @sql=@sql+datediff+char(40)+'endviptime,'+getDate()+char(41)+'<0'
if (@endtime='0' and @sql<>'')
  set @sql=@sql+' and '+datediff+char(40)+'endviptime,'+getDate()+char(41)+'=0'
else if(@endtime='0' and @sql='')
  set @sql=@sql+datediff+char(40)+'endviptime,'+getDate()+char(41)+'=0'
if (@sql<>'')
  set @sql='select username,companyname,createtime,endviptime,vb_id from admin_vcompanybase where isvip=1 and '+@sql
else
  set @sql='select username,companyname,createtime,endviptime,vb_id from admin_vcompanybase mowhere isvip=1'
exec(@sql)
GO


Ïà¹ØÎÊ´ð£º

SQLÓï¾äЧÂÊÎÊÌâ - ÆäËûÊý¾Ý¿â¿ª·¢ / ÆäËûÊý¾Ý¿â

´ó¼Ò°ïæ¿´¿´Õâ2¸ösqlÓï¾äÄĸö²éѯµÄËٶȸü¿ìµã¡£Ð»Ð»°ïæ¡£±È½Ï׿±¡£ÔÚ×öÐÔÄܲâÊÔ¡£
select * from
  ±íA LEFT OUTER JOIN ±íB ON (±íA.id || ' ' =±íB.id) ,±íC , ±íD, ±íE
WhereÆäËûÌõ¼þ
select * ......

SqlÅÅÐò - MS-SQL Server / »ù´¡Àà

ÎÒµÄTblworkbill±íµÄÊý¾ÝÈçÏÂ:
id workbillno ..................
1 1
2 6
3 a1
4 c2
5 2
6 aa
7 ......

Èç¹ûдµÝ¹ésqlÓï¾ä - MS-SQL Server / Ó¦ÓÃʵÀý

ÓÐÁ½¸öͬÑùµÄ±í½á¹¹ 
±í½á¹¹ÈçÏ£º
  id£¨ÐòºÅ£© parentid £¨¸¸½áµãÐòºÅ£© name(½áµãÃû³Æ)
 ±í1 ¼Ç¼ 1 0 aaa
  2 ......

ÇóÒ»sql¡¾Ð»Ð»¡¿ - MS-SQL Server / »ù´¡Àà

ÐèÇóÈçÏ£º
a±í:
 p_id status  
  1 0
  2 0
b±í
rec_id pid purchase_qty receive_qty flag
1 1 10 10 0
2 ......

sqlËÙ¶ÈÂýµÄÎÊÌâ - Oracle / »ù´¡ºÍ¹ÜÀí

select a.exec_sqn, a.dept_code 
  from ipmonmex a, lis_test_reg b 
where a.exec_sqn = b.exec_sqn 
  and b.barcode = '1002052716' 
Ö´ÐÐËٶȵÄ2·ÖÖÓ×óÓÒ£¬ÊµÔÚÊÇÌ«Â ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ