我有一张表使用外部数据到达切断。我可以从没有切断的表中完成它(因为它们使用替代的外部数据)吗?
在此示例中,可以使用各自表中的匹配数据完成第2行和第3行。
$link = "<a href='some-dynamic-link'>Text to replace</a>";
$newText = "Replaced!";
$result = preg_replace('/(<a.*?>).*?(<\/a>)/', '$1'.$newText.'$2', $link);
答案 0 :(得分:0)
要完成行,您可以选择并更新说明。
update Table1 set Description = (select Description from TableX where Description LIKE 'A long line th%' limit 1);
update Table1 set Description = (select Description from TableY where Description LIKE 'This line d%' limit 1);
要选择没有更新表,您可以
select tb1.Table as Proyect, tb1.Type, (select Description from TableX where Description like CONCAT(tb1.Description,'%')) from Table1 tb1 where tb1.Table = 'X'
UNION
select tb1.Table as Proyect, tb1.Type, (select Description from TableY where Description like CONCAT(tb1.Description,'%')) from Table1 tb1 where tb1.Table = 'Y';
这可能对某人有帮助,
INSERT INTO Table1 (
select 'X' as Project, Type, Description from Table1
UNION
select 'Y' as Project, Type, Description from Table2);
也许你的Table1.Description是错误的。
ALTER TABLE Table1 MODIFY COLUMN Description varchar(200);
答案 1 :(得分:0)
尝试这样的事情......
SELECT `Table` as Project,Type,Description
FROM Table1 T1 WHERE Type = 'A'
UNION ALL
SELECT `Table`,T1.Type,T2.Description
FROM Table1 T1 INNER JOIN TableX T2
ON T1.`Table` = 'X' AND T1.Type = 'B' AND T1.Type = T2.Type
UNION ALL
SELECT `Table`,T1.Type,T2.Description
FROM Table1 T1 INNER JOIN TableY T2
ON T1.`Table` = 'Y' AND T1.Type = 'B' AND T1.Type = T2.Type
http://www.sqlfiddle.com/#!9/b40a3/6
SELECT `Table` as Project,Type,Description
FROM Table1 T1 WHERE Type = 'A'
UNION ALL
SELECT `Table`,T1.Type,T2.Description
FROM Table1 T1 INNER JOIN TableX T2
ON T1.`Table` = 'X' AND T1.Type = 'B' AND T1.Type = T2.Type
AND T2.Description like CONCAT(T1.Description,"%")
UNION ALL
SELECT `Table`,T1.Type,T2.Description
FROM Table1 T1 INNER JOIN TableY T2
ON T1.`Table` = 'Y' AND T1.Type = 'B' AND T1.Type = T2.Type
AND T2.Description like CONCAT(T1.Description,"%")
如果您尝试匹配说明,则可以使用类似
的内容