我正在建立一个测试数据库。我有一堆专栏,我想清理敏感信息,以便我能处理。
id email
1 [email protected]
2 [email protected]
# email#@no-reply.com
我想要做的基本工作是 UPDATE Table SET 电子邮件 = "email" + id+ "@no-reply.com
我本来想在皮顿做这个的, 但以为在SQL做会更容易些。
我正在建立一个测试数据库。我有一堆专栏,我想清理敏感信息,以便我能处理。
id email
1 [email protected]
2 [email protected]
# email#@no-reply.com
我想要做的基本工作是 UPDATE Table SET 电子邮件 = "email" + id+ "@no-reply.com
我本来想在皮顿做这个的, 但以为在SQL做会更容易些。
对于你的情况,这将是:
UPDATE table
SET email = CONCAT( "email", id, "@no-reply.com" );
我刚刚用在我自己的桌子上late
of mysql。 以下是结果:
mysql> update late
-> set msg = concat( id, " ", msg );
Query OK, 74397 rows affected (4.15 sec)
Rows matched: 74397 Changed: 74397 Warnings: 0
是的, 如果您正在使用更新, 您应该已经拥有 ID 。 如果是 php, 看起来像 :
$query = Update email set email="email .$id. @no-reply.com where email.id= .$id;
此处 $query
是您正在构建的查询字符串, $id
是您用于引用记录的记录代号。
UPDATE table_reference
SET col_name1={expr1|DEFAULT} [, col_name2={expr2|DEFAULT}] ...
[WHERE where_condition]
[ORDER BY ...]
[LIMIT row_count]
对于单表语法, < 强度> UPDATE 强度 > 语句以新值更新指定表格中现有行列的值。 < 强度> SET < /强度 > 条款指定了要修改的列和应给定的值。 每种值都可以以表达式表示, 或关键词 < 强度 > DefAUTE 强度 > 来设定一个直观的列。 如果给定了 < 强度 > where 强度 > 条款, 则指定了要更新的行的条件。 在 < 强度 > no hher < /强度 > 条款中, 所有行都会更新。 如果指定了 < 强度 > ORDER < by < 强度 > /强度 > 条款, 则按指定的顺序对行进行更新。 < 强度 > LIMIT < /强度 > 条款对可以更新的行数设置限制。
I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...
<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...
我把我的用心从使用QQL转向MySQL。 它与凯科特合作,现在不工作,因为我已经改变,使用MySQL。 这里的错误信息是:
We have a restaurant table that has lat-long data for each row. We need to write a query that performs a search to find all restaurants within the provided radius e.g. 1 mile, 5 miles etc. We have ...
Is it possible in php to return a specific row of data from a mysql query? None of the fetch statements that I ve found return a 2 dimensional array to access specific rows. I want to be able to ...
Our website was developed with a meta tag set to... <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> This works fine for M-dashes and special quotes, etc. However, I ...
What are some of the strategies being used for pagination of data sets that involve complex queries? count(*) takes ~1.5 sec so we don t want to hit the DB for every page view. Currently there are ~...
My table looks like person_id | car_id | miles ------------------------------ 1 | 1 | 100 1 | 2 | 200 2 | 3 | 1000 2 | 4 | 500 I need to ...