1.表备份
INSERT INTO table1 SELECT * FROM table2;
2.用一个表中的字段更新另一张表中的字段
UPDATE table2
JOIN table1 ON table2.id = table1.id
SET table2.column2 = table1.column1;
3.在MySQL中,查询一个表的列字段值是否包含另一个表的字段,你可以使用LIKE
操作符
假设你有两个表:table1
和 table2
。
table1
有列 column1
和 column2
。
table2
有列 field1
。
你想找出所有在 table1
中,其 column1
的值包含 table2
的 field1
值的记录。
你可以使用以下的SQL查询:
SELECT *
FROM table1
WHERE column1 LIKE CONCAT('%', (SELECT field1 FROM table2 WHERE ...), '%');
示例:
SELECT
*
FROM
sys_user u
LEFT JOIN sys_dept d ON d.DEPT_NAME LIKE CONCAT( '%&#