SQL Query在前缀和非前缀字段上连接两个表(SQL Query that joins two tables on a prefixed and non prefixed field)
我的Access数据库中有两个表a和b 。 在两个表中我都有字段ID。 但是在表格中,我的ID字段以“31”为前缀,而表b中的 ID字段则不是。
所以举个例子
table a table b ID field2 ID field3 31L123 test123 L123 123test 31L122 test321 L122 321test
我的前缀字段表是从Excel导出定期导入的,我知道我可以删除excel级别的前缀但是有没有办法通过在SQL中的连接上使用某种Concatenate函数来连接ID字段上的两个表什么机会声明?
例如,类似的东西:
SELECT Id, Field2, Field3 FROM a LEFT JOIN b ON CONCATENATE('31', a.ID) = b.ID WHERE a.Field2 = 13
我不确定这是否是正确的方法 - 这就是为什么我似乎无法找到任何关于我的问题的现有帮助(忽略在导入之前处理excel级别的字段)。
I have two tables a and b in my Access Database. In both tables I have the field ID. However in table a my ID field is prefixed with '31' where as my ID field in table b is not.
So for example
table a table b ID field2 ID field3 31L123 test123 L123 123test 31L122 test321 L122 321test
My prefixed field table is imported regularly from an Excel export, I understand I could remove the prefix at the excel level but is there a way to join the two tables on the ID field by using some sort of Concatenate function on the join within the SQL statement by any chance?
So for example something along the lines of:
SELECT Id, Field2, Field3 FROM a LEFT JOIN b ON CONCATENATE('31', a.ID) = b.ID WHERE a.Field2 = 13
I am not sure if this is the correct approach or not - and that is why I can not seem to find any existing help on my problem (ignoring processing the fields at the excel level before the import).
原文:https://stackoverflow.com/questions/36063830
最满意答案
您需要调用该函数,而不仅仅是引用var。
如果你的
ns
有这个:(:require [bene-csv.core :as bcsv])
然后你需要在命名空间/别名限定的var周围加上括号来调用它:
(let [benetrak-csv-data (bcsv/ret-csv-data arg)] ; stuff )
You need to invoke the function, not just reference the var.
If you have this in your
ns
:(:require [bene-csv.core :as bcsv])
Then you need to put parentheses around the namespace/alias qualified var to invoke it:
(let [benetrak-csv-data (bcsv/ret-csv-data arg)] ; stuff )
相关问答
更多-
您可能希望:require命名空间a和b而不是:use 。 :use实时命名空间符号到当前命名空间,从而产生冲突。 You probably wanted to :require the namespaces a and b instead of :use. :use interns the namespace symbols to the current namespace, thus the conflict.
-
它应该工作 你确定为clojure.lang.IPersistentMap提供你自己的实现是行不通的吗? 它适用于我的REPL会话。 它甚至可以在我覆盖clojure.lang.Associative的默认实现时工作: user=> (ns ns1) ;;=> nil ns1=> (defprotocol IPrintable (prnt [this])) ;;=> IPrintable ns1=> (extend-protocol IPrintable clojure.lang.Associative ...
-
Clojure编译器执行一次传递,因此顺序无关紧要。 Clojure提供了一种指定前向声明的方法: (declare doWhatever1) 参见clojure.core / declare The Clojure compiler does a single pass so order does matter. Clojure does provide a way to specify forward declarations: (declare doWhatever1) See clojure.c ...
-
intern是正确的解决方案,您可以在自己的任何功能/宏中使用它。 (函数可以调用intern ;宏可以扩展为代码调用intern 。) def应该只在顶层直接使用或嵌套在顶级表单中,一旦顶级表单立即执行,它将立即执行。 因此, def in let很好,函数中的def不是。 def接收来自编译器的特殊处理,因为def表格中定义的Vars是在编译def立即创建的; 但是,如果控制流实际到达def形式,则安装def表单中指定的初始绑定。 这解释了为什么binding示例不起作用 - 它是*ns*的编译时值,它 ...
-
它在你使用eval时工作: user=> (with-err-str (eval '(defn - [] 11))) "WARNING: - already refers to: #'clojure.core/- in namespace: user, being replaced by: #'user/-\n" user=> (re-seq #"WARNING" (with-err-str (eval '(defn / [] 11)))) ("WARNING") 或者你可以在用户代码中重新定义defn宏 ...
-
您需要调用该函数,而不仅仅是引用var。 如果你的ns有这个: (:require [bene-csv.core :as bcsv]) 然后你需要在命名空间/别名限定的var周围加上括号来调用它: (let [benetrak-csv-data (bcsv/ret-csv-data arg)] ; stuff ) You need to invoke the function, not just reference the var. If you have this in your ns: (: ...
-
我用lein new compojure-app创建了一个应用lein new compojure-app ,当:debug值是真的,需要clojure.string :as str然后还打印一些东西到shell。 下面的代码通过lein ring server 。 我测试了它:debug值true和false 。 我在你的例子中看到,你使用environ ,我把{:debug true}或{:debug false}放在.lein-env 。 (ns integralist.handler ...
-
clojure中的命名空间(namespace in clojure)[2023-12-13]
我可以看到两个问题。 首先,Clojure要求ns名称使用 - 字符,其中文件名使用_字符(你不能真正使用 - 在ns名称或_在文件名中); 所以,你需要使用 (ns shell-space) 在文件的顶部。 其次,您的启动程序脚本不使用$ CLASSPATH环境变量,而是使用$ CLOJURE_CLASSPATH。 根据您的喜好调整,一切都应该很好。 为了完整起见:您需要将该.clj文件放在位于文件系统层次结构中类路径上的一个目录下的目录中。 例如,如果你把〜/ dev / projects /日记放在 ... -
如何在Clojure中获得命名空间中定义的所有函数?(How do you get all the functions defined in the namespace in Clojure?)[2022-07-19]
您可以使用ns-map函数和*ns*变量。 (ns-map *ns*) clojure.org命名空间页面上列出了所有命名空间函数。 You can use the ns-map function along with the *ns* variable. (ns-map *ns*) All the namespace functions are outlined on the clojure.org namespaces page.