javaʱ¼äº¯Êý£¬ÒÔ¼° sql ʱ¼ä·¶Î§²éÕÒ ´úÂë
String keyword = request.getParameter("keyword");
String timeRange = request.getParameter("timeRange");
String type = request.getParameter("type");
StringBuffer sql = new StringBuffer();
sql.append("use webstation_leadall select f.id,f.title,f.publishtime from information f left join infotype t on f.typeid=t.id where ");
if( (keyword == null)|| (keyword.equals("")) ){
sql.append("title like '%' and ");
}else {
sql.append("title like '%"+keyword +"%' and ");
}
if(timeRange.equals("")||timeRange==null){
sql.append("");
}else{
//Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd kk:mm:ss");
//String now = sdf.format(cal.getTime());
String begintime = "";
String endtime = "";
java.util.Date myDate=new java.util.Date();
long myTime = 0;
if(timeRange.equals("1")){
myTime=((myDate.getTime()/1000)-60*60*24)*1000;
begintime = sdf.format(new java.util.Date(myTime));
endtime = sdf.format(myDate);
//System.out.println("------"+begintime+"+++++"+endtime);
}else if(timeRange.equals("3")){
myTime=((myDate.getTime()/1000)-60*60*24*3)*1000;
begintime = sdf.format(new java.util.Date(myTime));
endtime = sdf.format(myDate);
//System.out.println("------"+begintime+"+++++"+endtime);
}else if(timeRange.equals("7")){
myTime=((myDate.getTime()/1000)-60*60*24*7)*1000;
&n
Ïà¹ØÎĵµ£º
select * from pet;
insert into pet values('Liujingwei','Liuchao','cat','f','1984-04-18',null);
UPDATE pet set birth='1989-08-31' WHERE name='Slim';
select * from pet WHERE birth>'1998-1-1';
SELECT * from pet WHEREselect * from pet;
insert into pet values('Liujingwei','Liuchao','cat','f','198 ......
½¨±í£º
CREATE TABLE [DB.dbo].tableName
(Stud_id int CONSTRAINT constraintName1 not null primary key,
Name nvarchar(5) not null,
Birthday datetime,
Gender nchar(1),
Telcode char(12),
Zipcode char(6) CONSTRAINT constraintName2 CHECK(zipcode like [ ......
Ò»¡¢¼òµ¥²éѯ
¡¡¡¡ ¼òµ¥µÄTransact-SQL²éѯֻ°üÀ¨Ñ¡ÔñÁÐ±í¡¢from×Ó¾äºÍWHERE×Ӿ䡣
ËüÃÇ·Ö±ð˵Ã÷Ëù²éѯÁС¢²éѯµÄ
±í»òÊÓͼ¡¢ÒÔ¼°ËÑË÷Ìõ¼þµÈ¡£
ÀýÈ磬ÏÂÃæµÄÓï¾ä²éѯtesttable±íÖÐÐÕÃûΪ“ÕÅÈý”µÄnickname×ֶκÍemail×ֶΡ£
SELECT nickname,email
from testtable WHERE name='ÕÅÈý'
(Ò»)Ñ¡ÔñÁбí
¡ ......
if exists(select 1 from sysobjects where name='char_index')
drop function char_index
create function char_index(@string varchar(8000),@char varchar(10),@index smallint)
--@string:´ý²éÕÒ×Ö·û´®£¬@index:²éÕÒλÖÃ
returns smallint
as
begin
declare
@i tinyint,--µ±Ç°ÕÒµ½µÚ@i¸ö
  ......