简体   繁体   English

SQL将内容从1个表移动到另一个基于行ID的位置

[英]SQL move content from 1 table to another based where row id

i have 2 tables in my mysql database and i need to move content from 1 column to another column in a 2nd table where the key is the same. 我在mysql数据库中有2个表,我需要将内容从1列移到第二个表中键相同的另一列。

As the example table 1 (o8hcn_j_content) has a column called jr_businessdescription. 作为示例,表1(o8hcn_j_content)具有称为jr_businessdescription的列。

I want to move the entries in this column into a column named fulltext in a 2nd table called (o8hcn_content) The tables don't have entries in teh same order so i want to match this update where the field in the first table (o8hcn_j_content) called contentid matches the id field of table 2. 我想将此列中的条目移动到名为(o8hcn_content)的第二张表中名为fulltext的列中。这些表没有相同顺序的条目,因此我想将此更新与第一个表中的字段(o8hcn_j_content)匹配称为contentid的表2的id字段匹配。

I've tried lots of ways here are the three I had thought would work but didn't: 我尝试了很多方法,这是我认为可以使用的三种方法,但是没有用:

UPDATE o8hcn_content SET fulltext = (o8hcn_j_content.jr_businessdescription FROM o8hcn_jreviews_content t2 WHERE o8hcn_j_content.contentid = o8hcn_content.id)

UPDATE o8hcn_content 
SET o8hcn_content.fulltext=o8hcn_j_content.jr_businessdescription,  
WHERE o8hcn_content.id=o8hcn_j_content.contentid;

UPDATE o8hcn_content
SET o8hcn_content.fulltext=o8hcn_j_content.jr_businessdescription
FROM o8hcn_content
INNER JOIN o8hcn_jreviews_content
ON o8hcn_content.id=o8hcn_j_content.contentid

The correct MySQL syntax is: 正确的MySQL语法为:

UPDATE o8hcn_content JOIN
       o8hcn_jreviews_content
       ON o8hcn_content.id = o8hcn_j_content.contentid
    SET o8hcn_content.fulltext = o8hcn_j_content.jr_businessdescription;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 sql将行从一个表移动到另一个表 - sql move row from one table into another SQL将行从一个表移动到另一个表,具有不匹配的列 - SQL move row from one table to another with unmatched columns 从表中获取用户,其中group = group另一个表行,但是我有另一个表行的id - Get users from table where group=group of another table row but i have id of other table row 使用第一个表中的某些内容作为接收表的列,将数据从SQL中的一个表移动到另一个表中 - Move data from a table to another table in SQL using some of the first table content as columns of the receiving table 从表中选择行,其中具有相同id的另一个表中的行在另一列中具有特定值 - Select rows from a table where row in another table with same id has a particular value in another column MySQL 从基于 email 的表中获取 ID 然后使用 ID 和更多值在另一个表中创建一行 - MySQL get ID from a table based on email then create a row in another table using ID and more values 我可以从一个ID =另一个查询的表中选择全部的SQL查询吗? - Can I have an SQL query where I select all from a table where ID = another query? SQL根据另一行中的值更改id的另一行 - SQL Change another row for id based off of value in a different row 如果该 id 不存在该行,则 SQL 为从另一个表返回的每个 id 插入多行 - SQL Insert multiple rows for every id returned from another table if the row does not exist for that id 根据另一个表中的另一个特定值在SQL表中插入ID - Insert id in sql table based on another particular value in another table
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM