Suppose that one of the tables in PostgreSQL 10 database is called 'Measurement' and has (among others) a column called 'Name' of text type.
I would like to list all records with specific name, so sql statement:
SELECT * FROM public."Measurement" WHERE "Measurement"."Name" = 'nazwa1';
works fine in pgAdmin SQL editor.
I would like to ask server about the same but with psql working in command line on Ubuntu, something like this:
psql --host 127.0.0.1 --dbname BazaDanych --username postgres --port 5432 --echo-all --no-align --command 'SELECT * FROM public."Measurement" WHERE "Measurement"."Name" = 'nazwa1';' --log-file /home/user/wynik.log -o /home/user/dane.csv -P fieldsep=',' -P footer='off'
It does not work since single quotation mark from this statement is not recognized by shell and it causing problem reported as "column does not exist",as follows:
public."Measurement" WHERE "Measurement"."Name" = nazwa1
'nazwa1' string is not interpreted as a value to be compared with the records but as a column name.
I have tried many ways, as: \', doubling single quotation mark and many others but with no successful results.
How to workaround this ? Could someone correct my command ?