Questions And Answers

More Tutorials



In this topic we will base on this table of users :
CREATE TABLE sch_test.user_table
 id serial NOT NULL,
 username character varying,
 pass character varying,
 first_name character varying(30),
 last_name character varying(30),
 CONSTRAINT user_table_pkey PRIMARY KEY (id)

| id | first_name | last_name | username | pass |
| 1 | hello | world | hello | word |
| 2 | root | me | root | toor |


Select every thing:

SELECT * FROM schema_name.table_name WHERE <condition>;

Select some fields :

SELECT field1, field2 FROM schema_name.table_name WHERE <condition>;


-- SELECT every thing where id = 1
SELECT * FROM schema_name.table_name WHERE id = 1;
-- SELECT id where username = ? and pass = ?
SELECT id FROM schema_name.table_name WHERE username = 'root' AND pass = 'toor';
-- SELECT first_name where id not equal 1
SELECT first_name FROM schema_name.table_name WHERE id != 1;


In this page (written and validated by ) you learned about postgreSQL SELECT . What's Next? If you are interested in completing postgreSQL tutorial, your next topic will be learning about: postgreSQL Table Creation.

Incorrect info or code snippet? We take very seriously the accuracy of the information provided on our website. We also make sure to test all snippets and examples provided for each section. If you find any incorrect information, please send us an email about the issue:

Share On:

Mockstacks was launched to help beginners learn programming languages; the site is optimized with no Ads as, Ads might slow down the performance. We also don't track any personal information; we also don't collect any kind of data unless the user provided us a corrected information. Almost all examples have been tested. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. By using, you agree to have read and accepted our terms of use, cookies and privacy policy.