sql - Substring in postgres -
i have 2 tables in postgres trying compare , having trouble accessing substring 1 , comparing one. i'm new postgres (specifically sql through pgadmin), suggestions helpful.
i trying count number of id numbers similar between 2 tables, 1 set of numbers longer other due concatenated fips code. don't want trim data if don't have to, right have:
select count(id_a) server.table1 where(id_a not null , id_a in (select (substring(id_b 3 8) server.table 2)))
i answer because little catch on query. if typo delete after update original question.
select count(id_a) server.table1 ( id_a not null , id_a in (select (substring(id_b 3 8) server.table2) ) ^ ) |_ parenthesis in wrong place
note either missing parenthesis or excessive one.
the right query be:
select count(id_a) server.table1 id_a not null , id_a in (select substring(id_b 3 8) server.table2)
as @ziggycrueltyfreezeitgeister pointed out, don't need id_a not null
if don't have null values on it.