Require clarity in SQL course - creating copy of table

Hello!

I’m doing the exercise for ‘creation copy of a table’ but I could not insert the data because I used

create table invoice_archive2 as
SELECT * 
FROM clients  c
JOIN invoices inv
ON 	c.client_id = inv.client_id
WHERE payment_date IS NOT NULL

instead of

create table invoice_archive2 as
SELECT * 
FROM clients  c
JOIN invoices inv
USING (client_id)
WHERE payment_date IS NOT NULL

I was under the assumption that USING (client_id) is a shorthand for what I did, so why did it not work? Can someone assist in clarification? I’d very much appreciate it.

Similar but not a shorthand in some cases. The key difference being ON will map the tables together using 2 explicitly stated values.

Whereas USING has to have 2 values that are exactly the same on both tables, and not just named the same but the same values. This is where the trouble lies if they are named the same but different.

But in some cases yes a shorthand, however ON is much safer and more flexible generally. Using is cleaner syntax but limited use case.