mysql查询是做什么的_什么是简单的mysql查询

我想获取客户信息,其中客户ID应为2,log_id应为最大值

我试过下面的查询,但它找到了第一条记录.

什么是简单的查询

mysql> select * from log_customer where customer_id =2 group by customer_id having max(log_id);

+--------+------------+-------------+---------------------+-----------+----------+

| log_id | visitor_id | customer_id | login_at | logout_at | store_id |

+--------+------------+-------------+---------------------+-----------+----------+

| 2 | 56 | 2 | 2010-02-19 19:34:45 | NULL | 1 |

+--------+------------+-------------+---------------------+-----------+----------+

1 row in set (0.00 sec)

mysql> select * from log_customer where customer_id =2 limit 5;

+--------+------------+-------------+---------------------+---------------------+----------+

| log_id | visitor_id | customer_id | login_at | logout_at | store_id |

+--------+------------+-------------+---------------------+---------------------+----------+

| 2 | 56 | 2 | 2010-02-19 19:34:45 | NULL | 1 |

| 3 | 114 | 2 | 2010-02-23 17:31:55 | NULL | 1 |

| 31 | 1854 | 2 | 2010-03-08 18:31:28 | 2010-03-08 18:56:49 | 1 |

| 32 | 1992 | 2 | 2010-03-09 01:12:43 | NULL | 1 |

| 33 | 2304 | 2 | 2010-03-09 14:42:39 | NULL | 1 |

+--------+------------+-------------+---------------------+---------------------+----------+

请不要通过log_id desc建议订单我不想这样做

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值