mysql

<pre class="sql" name="code">INSERT INTO `mail_table` (title,sender_id,sender_name,recver_id,recver_name,body,item_id,Item_num,expire,create_time) 
SELECT '补偿','0','',id,name,'批量邮件','7675','1',UNIX_TIMESTAMP(NOW()), FROM

#group by 唯一账号 保存到tb表
(SELECT * FROM `char_table` WHERE LEVEL >= 20 GROUP BY account_id) AS tb


 

通过别的表获取id发送邮件


mysql> select * from t1;
+---+---+
| i | j |
+---+---+
| 1 | 1 |
| 2 | 2 |
+---+---+
mysql> select * from t2;

+---+---+
| k | j |
+---+---+
| 3 | 1 |
| 2 | 2 |
+---+---+

join on 加入表(扩充列) on作为id关联

mysql> select * from t2 join t1 on (t1.j = t2.j);
;
+---+---+---+---+
| k | j | i | j |
+---+---+---+---+
| 3 | 1 | 1 | 1 |
| 2 | 2 | 2 | 2 |
+---+---+---+---+

union和union all联合(扩充行)

需要保证列数相同,union会把重复行过滤,union all会显示全部。


select * from t1 union (select * from t2);

+---+---+
| i | j |
+---+---+
| 1 | 1 |
| 2 | 2 |
| 3 | 1 |
+---+---+

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值