postgresql
고르다
수색…
WHERE를 사용하여 SELECT
이 항목에서는이 사용자 테이블을 기반으로합니다.
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 * FROM schema_name.table_name WHERE <condition>;
일부 입력란을 선택하십시오.
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;
Modified text is an extract of the original Stack Overflow Documentation
아래 라이선스 CC BY-SA 3.0
와 제휴하지 않음 Stack Overflow