帐号表结构如下: CREATE TABLE `t_account` ( `account_id` int(10) unsigned NOT NULL auto_increment COMMENT '所属帐号id', `account_name` varchar(50) NOT NULL COMMENT '帐号名', `password` varchar(16) NOT NULL COMMENT '密码', `last_login_time` timestamp NOT NULL default '1979-01-01 00:00:00' COMMENT '最后登录时间', `point` int(10) unsigned NOT NULL default '0' COMMENT '积分', PRIMARY KEY USING BTREE (`account_id`), ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8; CREATE TABLE `t_account_nickname` ( `account_id` int(10) unsigned NOT NULL COMMENT '所属帐号id', `account_nickname `varchar(50) NOT NULL COMMENT'昵称', PRIMARY KEY USING BTREE (`account_id`), ) ENGINE=InnoDB DEFAULT CHARSET=utf8; 请写出SQL语句(温馨提示:列点作答,字体端正,代码细节与规范) 1.查询最近1000个登录的帐号(mysql) 2.查询如下结果:第一列帐号ID,第二列帐号名,第三列昵称,第四列积分 3.对帐号名里包含rock的帐号,积分修改为0 4.查询出重复的昵称
时间: 2024-01-13 14:03:10 浏览: 75
无法解析的外部符号”private: char * __cdecl cv::String::allocate(unsigned __int64)” (?allocate@String@cv@@AEAA
1. 查询最近1000个登录的帐号(mysql)
```
SELECT account_id, account_name, last_login_time, point
FROM t_account
ORDER BY last_login_time DESC
LIMIT 1000;
```
2. 查询如下结果:第一列帐号ID,第二列帐号名,第三列昵称,第四列积分
```
SELECT t1.account_id, t1.account_name, t2.account_nickname, t1.point
FROM t_account AS t1
LEFT JOIN t_account_nickname AS t2 ON t1.account_id = t2.account_id;
```
3. 对帐号名里包含rock的帐号,积分修改为0
```
UPDATE t_account
SET point = 0
WHERE account_name LIKE '%rock%';
```
4. 查询出重复的昵称
```
SELECT account_nickname, COUNT(*) AS num
FROM t_account_nickname
GROUP BY account_nickname
HAVING num > 1;
```
阅读全文