Chinaunix首页 | 论坛 | 博客
  • 博客访问: 72017
  • 博文数量: 33
  • 博客积分: 2000
  • 博客等级: 大尉
  • 技术积分: 305
  • 用 户 组: 普通用户
  • 注册时间: 2009-07-17 15:59
文章分类

全部博文(33)

文章存档

2011年(1)

2010年(6)

2009年(26)

我的朋友

分类: Mysql/postgreSQL

2009-08-05 11:57:56

mysql> select * from alert_config limit 1;    
                                                                                     
+----+---------------+-------------+-------------+------------+------+--------+---------------------+
| id | ip            | description | explanation | upperLimit | type | status | createTime          |
+----+---------------+-------------+-------------+------------+------+--------+---------------------+
|  1 | 192.168.0.126 | | NULL        |         90 |    1 |      0 | 2009-06-24 12:00:53 |
+----+---------------+-------------+-------------+------------+------+--------+---------------------+
1 row in set (0.00 sec)
 
mysql> select * from alert_mobile_history_log limit 1; 
                                                                            
+----+---------+-------+---------------------+
| id | alertId | value | createTime          |
+----+---------+-------+---------------------+
|  1 |       1 | 0     | 2009-06-24 11:55:03 |
+----+---------+-------+---------------------+
1 row in set (0.00 sec)
 
mysql> select a.ip,b.alertId,a.description,b.value,b.createTime from alert_config as a,alert_mobile_history_log as b where a.id=b.alertId limit 1;
                                                                                        
+---------------+---------+-------------+-------+---------------------+
| ip            | alertId | description | value | createTime          |
+---------------+---------+-------------+-------+---------------------+
| 192.168.0.126 |       1 | | 0     | 2009-06-24 11:55:03 |
+---------------+---------+-------------+-------+---------------------+
1 row in set (0.00 sec)
 
要把description 字段下的@value@替换为value字段下的值。
 
mysql> select a.ip,b.alertId,replace(a.description,'@value@',b.value) as value2,b.createTime from alert_config as a,alert_mobile_history_log as b where a.id=b.alertId limit 1;
                                                         
+---------------+---------+--------+---------------------+
| ip            | alertId | value2 | createTime          |
+---------------+---------+--------+---------------------+
| 192.168.0.126 |       1 | cpu0%  | 2009-06-24 11:55:03 |
+---------------+---------+--------+---------------------+
1 row in set (0.00 sec)
 
查询value2字段下有load的数据。
 
mysql> select a.ip,b.alertId,replace(a.description,'@value@',b.value) as value2,b.createTime from alert_config as a,alert_mobile_history_log as b where a.id=b.alertId and value2 like 'load%' limit 1;  
ERROR 1054 (42S22): Unknown column 'value2' in 'where clause'
 
value2不能做为条件使用。
 
mysql> select a.ip,b.alertId,replace(a.description,'@value@',b.value) as value2,b.createTime from alert_config as a,alert_mobile_history_log as b where a.id=b.alertId and a.description like 'load%' limit 1;
+---------------+---------+-----------+---------------------+
| ip            | alertId | value2    | createTime          |
+---------------+---------+-----------+---------------------+
| 192.168.0.126 |       3 | load 0.00 | 2009-06-24 15:40:02 |
+---------------+---------+-----------+---------------------+
1 row in set (0.00 sec)
 
ok!
阅读(2239) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

eqplus2009-08-17 13:51:36

LAMP开发联盟QQ群:2292482 期待您的加入