MySQL数据表字段内容的批量修改、清空、复制等更新命令_MySQL
bitsCN.com
最近遇到一点麻烦事,新安装的PHPwind6.0正式版社区在导入之前的会员帐号资料时,发现很多会员的mail地址貌似胡乱填写的,之前的PHPwind5.5版本没有开启mail地址验证功能,所以估计很多用户胡乱填写了email地址,所以我就想要求所有正式会员重新验证邮件地址来重新激活会员帐号,结果发现社区根本没有这项功能,挣扎了N久,数据库的会员资料数据表被反复安装=删除了好几遍,总算找到了一个批量修改的方法。
不过这样操作会连社区创建者的账号都改成未激活,所以要是不清楚还真的不敢动手。
在PHPwind6.0的MySql数据库里,它的会员资料存在pw_members里面,会员帐号正常状态下这个数据表里的“yz”字段显示的值是1(即表示已经激活了帐号)。如果需要再次邮件激活,则这个值显示的内容必须与另一个字段"regdate"的值相同,程序在验证时自动检测两个字段的内容是否完全一样之后才会进行有效验证,否则会给出参数错误的提示。例如会员UID 1的“regdate”字段内容是1194067635,那么“yz”字段的值也一样是1194067635;以此类推,如果会员UID 2的“regdate”字段内容是1175320740,那么“yz”字段的值也一样是1175320740...
此时,由于可能的各种原因,“yz”字段的值可能并不是都是1(即表示已经激活了帐号)的状态,如何让“yz”字段的值和“regdate”字段内容保持一致呢?同时,因为会员资料N多,又如何批量转换所有会员帐号的这个字段值呢?
我用的方法是这样的
UPDATE table SET 被替换的字段名=被复制的字段名
应用到本文实例:
UPDATE pw_members SET yz=regdate
其中“pw_members”是数据表名称;“被替换的字段名”指的是在“pw_members”中你要修改的那个字段的名称,这里是“yz”;而“被复制的字段名”指的是提供字段内容给“yz”字段复制的字段名(好拗口哟!)“regdate”;这样可以批量将每个UID内的“yz”修改并复制成和“regdate”相同的值。而会员在下次登陆时社区就会要求他再次激活邮件帐号。
由于此举是批量修改,因为将会把包括社区创建者在内的所有账号都改成未激活,所以当执行完了以后,要立即把包括社区创建者在内不需要激活的账号改回正常状态。方法是在pw_members数据表的浏览状态下,选择你要改回正常状态的会员帐号,点击“编辑”进入之后找到“yz”字段,将字段的值例如“1194067635”改成“1”,这样这个会员帐号就恢复正常了;也可以用管理员帐号进入社区管理后台“会员管理”里将需要的会员ID手动激活。
另外,如何手动将同一数据表内不同字段之间的内容批量转换,可以参考下面的命令:
UPDATE table set 字段名=REPLACE(字段名,'原字符串','替换的字符串') where 已知的字段名 LIKE '%原字符串%'
应用到本文实例:
UPDATE pw_members set yz=REPLACE(yz,'1','2') where yz LIKE '%1%'
其中“pw_members”是数据表名称;“字段名”指的是在“pw_members”中你要修改的那个字段的名称,这里是“yz”;“原字符串”是字段“yz”现在默认的值“1”;而“替换的字符串”指的是你将要修改的字段“yz”新的默认值“2”。
如何批量将某个或某几个字段的数值清空?
UPDATE table set 字段名= '0' 清空字段数值
应用到本文实例:
UPDATE pw_memberdata set money= '0' 清空金币
UPDATE pw_memberdata set rvrc= '0' 清空威望
UPDATE pw_memberdata set credit= '0' 清空贡献值
UPDATE pw_memberdata set currency= '0' 清空交易币
UPDATE pw_memberinfo set deposit= '0' 清空活期存款
UPDATE pw_memberinfo set ddeposit= '0' 清空定期存款
UPDATE pw_membercredit set value= '0' 清空好评度
闪电博客评:文章网上找的,我的实际用法
mysql 更新(清空)某表某一字段内容:update 表名 set 字段名='',并没有0。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

1. How to buy WeChat reading membership cheaply? Share the best way to buy membership on WeChat Reading! 1. Open the WeChat Reading APP. There is a reading challenge in the reading welfare special session. Participate in the reading challenge. 2. Pay 1 yuan to participate, read for 7 days, duration >7 hours, and get a 4-day paid membership card with 4 book coins. You can participate for about 52 weeks in a year. If you participate every time, it will cost a total of 52 yuan, and you can get a total of 208 days. Paid membership card 208 book coins. 3. Pay 3 yuan to participate, read for 14 days, duration >14 hours, and get a 10-day paid membership card with 10 book coins. You can participate about 26 times a year. If you participate every time, it will cost a total of 78 yuan, and you can get a total of 260 days. Paid membership card costs 260 book coins. 4. Pay 4 yuan to participate and read for 21 days

QQ Music is a music-listening software used by many users. Some songs here require users to have membership before they can download and play them. So how to get QQ Music membership for free? Let this site give users a detailed introduction to the tutorial on how to obtain QQ Music membership for free. Tutorial on getting QQ Music membership for free 1. First, we open QQ Music. 2. Go to my homepage and click on the three horizontal lines in the upper right corner. 3. Click to open the free music listening mode here. 4. A 15-second advertisement will appear here. We only need to wait for the advertisement to end to get a thirty-minute membership experience. Experience time can be superimposed. 5. Obtain a membership after reading it. Receive 1 day of QQ music

How to cancel automatic membership renewal on Kugou Music APP? There are many users who have applied for Kugou Music’s VIP auto-renewal service. Later, they want to cancel this service, but they don’t know where to cancel it. Below, I will bring you a tutorial on how to cancel the auto-renewal of Kugou Music. I hope it will be helpful to everyone. . It is very simple to cancel automatic renewal in Kugou Music APP: just enter the member center, find the music package/luxury VIP option, select automatic renewal enabled, and then click to close renewal. 2. WeChat: As shown in the picture below, go to the payment page, click the three dots in the upper right corner, select the deduction service, click Kugou Music to close the service; 3. Alipay: Go to the settings page, select payment settings, and select password-free payment/ Automatically deduct fees, and finally choose Kugou Music to terminate the contract.

Bilibili is a video playback platform with rich resources, including a dance area, ghost animal area, food area, animal area, etc. But now many times you need to be a member to watch videos on site B. If you don’t want to spend money, can you get a member of site B? The editor here will bring you how to get the free membership of Bilibili. I hope it can help you. How to get free membership on Bilibili: Open Bilibili and click "My". Click the "Creation Home" icon in the "Creation Center" area. After entering the creation center, click "Task Center". After entering the task center, read the corresponding tasks and complete them to get points.

How to cancel the automatic renewal of Zhihu app membership? Zhihu app is a very practical mobile software. This software has many functions, and each function will bring a different feeling to the users. There are some contents on this software that require users to register as a member before they can read them. Membership on this software is not expensive, and continuous monthly membership will be cheaper. Some players want to know how to cancel automatic renewal. The editor below has compiled methods for canceling automatic renewal for your reference. How to cancel automatic renewal for Zhihu app members Zhihu members can choose four renewal methods, including Apple Pay, WeChat Pay, Alipay Pay and Baidu Pay. For users who choose Baidu Pay, renewal can be managed through WeChat or Alipay payment.

The "VIP membership" function in Xianyu APP is a value-added service provided to users. Users who become VIP members can enjoy a series of privileges and benefits, such as increased product exposure, more display opportunities, exclusive customer service, transaction guarantee upgrades, etc., which help improve users’ buying and selling experience and efficiency. How to become a member of Xianyu 1. First open the Xianyu software. After entering the homepage, you can switch to different pages. Here we click [My] in the lower right corner; 2. Then we can view many different pages in For information, we need to click [My Fish Value]; 3. After the final click, we can activate VIP membership on this page;

Ximalaya membership is a paid membership service that allows users to listen to audio content, download works of Ximalaya anchors, and enjoy more privileges and benefits. However, many users hope to receive free Himalaya membership to enjoy more audio resources. So, is there really a way to get a Himalayan membership for free? This article will share some methods and techniques to help readers better obtain Himalaya membership. First, we need to understand the basic situation of Himalaya members. Himalayan membership is divided into two types: ordinary members and professional members. general

Quark Network Disk is powerful and can store various types of files in various formats. Many users have recharged Quark Network Disk membership, but now they feel that they can no longer use it. How can they cancel the automatic membership renewal? The editor below will introduce to you how to turn off the automatic renewal function of Quark, come and take a look. Quark Network Disk Tutorial on Cancel Automatic Renewal 1. Open Alipay on your mobile phone and click [Settings] on my page. 2. Click [Payment Settings] and click [Password-free Payment/Automatic Deduction]. 3. Click on the Quark Network Disk Continuous Monthly Subscription Project and click [Close Service].
