Can I combine USING and ON in a single join?
09:47 05 May 2016

I'm using PostgreSQL 9.5. I'd like to have the column-merging functionality of USING in a query where not all of the columns that I'm using for the join are named the same. For example:

SELECT
 *
FROM table_a a
 INNER JOIN table_b b USING(shared_id) AND a.foo = b.bar

The above code doesn't work. Is there something I can write to get this effect? Or do I need to do ON a.shared_id = b.shared_id AND a.foo = b.bar?

postgresql