简体   繁体   English

引用另一个单元格中一个单元格的值(SQL)

[英]Reference a value from one cell in another cell (SQL)

I am not sure if this is possible. 我不确定这是否可能。 I have done a lot of searching but I keep finding answers about inserting a value one time, not keeping a reference. 我进行了很多搜索,但是我一直在寻找有关一次插入值而不是保留引用的答案。

At my work I am 'internationalising' some webpages, which means making a database entry for every piece of text. 在我的工作中,我正在将某些网页“国际化”,这意味着为每段文本创建一个数据库条目。 There is one piece of text that has a link in it, and the link is stored in the database already. 一段文本中有一个链接,该链接已经存储在数据库中。 Having the code that referenced the link in the database cell didn't work (it just printed out as plain text), so my solution was to have the first half on the paragraph as one database entry (ending in ...<a href=" ), and the second half as another (starting with ">click here</a>...), and have the reference to the link in the middle. 在数据库单元格中有引用链接的代码不起作用(它只是打印为纯文本),所以我的解决方案是将段落的前半部分作为一个数据库条目(以...<a href="结尾) ...<a href=" ),后半部分作为另一部分(以">click here</a>...),开头">click here</a>...),并在中间引用该链接。 However my supervisor didn't like that. 但是我的上司不喜欢那样。

So, what I would LIKE to be able to do, is have one database entry for the whole paragraph, and in the middle of it, refer to the link which is in another table (actually the same table, different sub-table). 因此,我很想做的是,在整个段落中都有一个数据库条目,在其中间,是指另一个表中的链接(实际上是同一表,不同的子表)。 That way, the link will stay updated if it is ever changed (rather than hard-coding it into the paragraph text). 这样,如果链接发生更改,链接将保持更新状态(而不是将其硬编码到段落文本中)。

If it is impossible, that's totally fine, just want to confirm it (I can't seem to find anyone else who wanted to do this same thing and has been told it's impossible). 如果不可能,那完全没问题,只想确认一下(我似乎找不到其他人想做同样的事情,并被告知这是不可能的)。

Thanks! 谢谢!

This is totally possible. 这完全有可能。 All you need to do is to design a trigger on the table at insert and update event. 您需要做的就是在插入和更新事件时在表上设计一个触发器 whenever the link is entered or updated, the trigger will update the paragraph column as per your coding inside the trigger. 无论何时输入或更新链接,触发器都会根据触发器中的编码来更新段落列。

If you can share the table and fields, I can help you to write that trigger too :) 如果您可以共享表和字段,我也可以帮助您编写触发器:)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM