【问题标题】:Joining table A and table B, both having column1 as common连接表 A 和表 B,两者的 column1 为 common
【发布时间】:2014-02-20 07:06:28
【问题描述】:

我有 2 张桌子 - TableA 和 TableB。两者都有column1 作为公共列。

但是在TableA 中,column1 中的数据是数字,例如 201,而在 TableB 中,column1 中的数据是 two hundred one 之类的单词。

其他列都不通用。

如何加入这些表格?我可以将to_char(todate(column1,'j'),jsp) 用于TableA 吗?

【问题讨论】:

  • 这个link 可能会有所帮助
  • 您可以为这些单词的数字版本创建另一列。

标签: sql


【解决方案1】:

在 Oracle 中可以使用 to_char 函数,但在 SQL 中,您需要为此转换编写一个函数,然后在查询中传递该函数。一个这样的例子是在这篇文章中找到的number_to_string 函数。

Converting Numbers to Words in MYSQL result! Using Query

使用这个函数你可以写一个类似的条件

number_to_string(TableA.numValue) = TableB.stringValue 在你的 JOIN 中获得想要的结果。

【讨论】:

    【解决方案2】:

    首先,最好有一些将整数转换为单词的函数,然后你可以使用标准的连接子句。

    This link can help you

    或

    this link

    【讨论】:

      猜你喜欢
      • 2021-03-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-18
      • 1970-01-01
      • 2019-07-29
      • 1970-01-01
      相关资源
      最近更新 更多