I'm running PostgreSQL 11.8 in a Docker container. I have two databases: website_db
and testdb
.
website_db
has a products table with id
, product_name
, colour
, product_size
columns
testdb
has a table called users with id
, username
, password
I'm using website_db
and I want to UNION
columns from the users table in the testdb
database. I can get this to work in MySQL but am struggling with Postgres. Here's my attempt:
SELECT * FROM products WHERE product_name = 'doesntexist' OR 1=1 UNION SELECT null,username,password,null FROM testdb.users;
I get this error back:
ERROR: relation "testdb.users" does not exist
LINE 1: ...1=1 UNION SELECT null,username,password,null FROM testdb.use...
Does anyone know what I have to do to fix my query?