假设我在Postgres中有两个表:
Name: table_rad
Column Type
id integer
username character varying(64)
Name: table_mac
Column Type
id integer
mac macaddr
我想进行一个连接操作:
SELECT * FROM table_rad WHERE username = mac;
Postgres会抱怨:
ERROR: operator does no exist: character varying = macaddr
LINE 1: ...ELECT * from table_rad WHERE username = mac;
^
Hint: No operator matches the given name and argument type(s). You might need to add explicit type casts.
我已经通过谷歌搜索了解到需要使用CAST来解决这个问题。但是如何将macaddr类型转换为varchar类型呢?