Home » SQL & PL/SQL » SQL & PL/SQL » hot to select those authors who live in the same zip area
hot to select those authors who live in the same zip area [message #2291] |
Wed, 03 July 2002 13:31 |
James
Messages: 120 Registered: June 2000
|
Senior Member |
|
|
The table can be created as follows.
I want to select those author live in Oakland, CA and in the same zip area.
SELECT au_fname,au_lname,zip
from sameRow
where STATE ='CA'
and CITY= 'Oakland'
??
Attached table creation sql.
drop table sameRow;
create table sameRow(
au_ID NUMBER (5) NOT NULL,
au_fname VARCHAR2(20),
au_lname VARCHAR2(20),
state VARCHAR2(20),
city VARCHAR2(20),
zip VARCHAR2(10)
);
insert into sameRow values (10001,'James','HU','CA','Oakland','12345');
insert into sameRow values (10002,'James1','HU2','CA','Oakland','32345');
insert into sameRow values (10003,'James2','HU3','CA','Oakland','12345');
insert into sameRow values (10004,'James3','HU4','CA','Toronto','416345');
insert into sameRow values (10005,'James4','HU5','CA','Los Angels','52321');
insert into sameRow values (10006,'James5','HU6','CA','Oakland','31234');
commit;
|
|
|
|
|
|
|
Re: hot to select those authors who live in the same zip area [message #2308 is a reply to message #2302] |
Thu, 04 July 2002 07:18 |
James
Messages: 120 Registered: June 2000
|
Senior Member |
|
|
Thanks a lot, but, ur code only works for the specific sample (ie. there are only 2 authors live in the same zip area), however, if there are more than 2 authors live in the same zip area, it doesn't work, we do not know how many authors live in the same area in advance.
I believe there should be better way.
James
|
|
|
Goto Forum:
Current Time: Fri Apr 19 15:15:51 CDT 2024
|