首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

求一MYSQL,该如何处理

2012-04-05 
求一MYSQLSQL codeSELECTID,Name,Time,IPFROMTableWHEREtime2012-01-04 00:00:00 and time2012-01-

求一MYSQL

SQL code
SELECTID,Name,Time,IPFROMTableWHEREtime>='2012-01-04 00:00:00' and time<='2012-01-10 23:59:59'


我想在这段基础上加上,所得到的IP是否为2012-01-04前就已经存在的?

[解决办法]
不会吧。
[解决办法]
真的不会吧
[解决办法]
探讨
我想在这段基础上加上,所得到的IP是否为2012-01-04前就已经存在的?

[解决办法]
猜测lz的意思为:想找到IP对应的日期在2012-01-04前就有的

SQL code
use tempdb;/*create table A(    ID int not null,    Name nvarchar(10) not null,    [Time] date not null,    IP nvarchar(20) not null);insert into A values(1,'a','2012-01-01','192.168.1.1'),(2,'b','2012-01-01','192.168.1.2'),(3,'a','2012-01-04','192.168.1.1'),(4,'c','2012-01-10','192.168.1.3');*/select B.ID,B.Name,B.[Time],B.IP from A AS Bwhere B.IP in(    select A.IP from A    where A.[Time] < '2012-01-04')and B.[Time] between '2012-01-04' and '2012-01-10';
[解决办法]
try
SQL code
SELECT ID,Name,Time,IP,case when   exists(select 1 TABLE where Time<='2012-01-03 23:59:59' and IP=t.IP)  then 'Yes'  else 'No'end as oldipFROM TableWHERE time>='2012-01-04 00:00:00' and time<='2012-01-10 23:59:59' 

热点排行
Bad Request.