Sql Help

Hello all...

I had a question and didn't know exactly how to go about it...

I have a sql database with about 5 columns and one of those columns being a "beat" consisting of codes.

What I would like to do is this:

In a separate table i have the "beats" along with the matching zip codes of a particular area. I would like to be able to append a 6th column named zip codes and according to a particular beat, assign a zip code in the 6th column. Does this make any sense? Is this possible and can it be done through a stored procedure of some sort.

thanks in advance...

jagsdj

[627 byte] By [jagsdj] at [2007-9-26 7:07:26]
# 1

I'm not completely clear about what you want to do - are you simply trying to retrieve the data or actually add the 6th column to the table?

If you are only trying to retrieve the data, you could get the zip code column with a two-table join, i.e.:

SELECT a.zip_codes

from beat_table A,

zip_table B

WHERE A.beats = B.beats

This will match the beats on each of the tables and then give you the zip codes. Is this at all what you are looking for?

turtle2520 at 2007-7-1 16:48:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 2
thanks for the reply "turtle..." I had read about the joins and that is, in part, what I was looking for. But I would also like to add the 6th column to the table...Any ideas?Thanks again for your help!jagsdj
jagsdj at 2007-7-1 16:48:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...
# 3
ALTER TABLE tableADD COLUMN column datatype;e.g.ALTER TABLE bADD COLUMN zip_code char(5);
rennie1 at 2007-7-1 16:48:06 > top of Java-index,Database Connectivity,Java Database Connectivity (JDBC)...