查询表中第一条或最后一条

SELECT * FROM user LIMIT 1;

SELECT * FROM user ORDER BY id ASC LIMIT 1;

SELECT * FROM user ORDER BY id DESC LIMIT 1;

以查询结果作为条件进行查询

SELECT id FROM auth_company WHERE user_id  = (SELECT id FROM user WHERE username='ut251') ORDER BY id DESC LIMIT 1;

 

posted on 2024-04-24 14:37  会锻炼的猪  阅读(2)  评论(0编辑  收藏  举报