[quoted text, click to view] Nudge wrote:
> hi,
>
> i am trying to run a asp sql query containging many tables.
>
> the main table though is a simple ID based table contains all ids
> from the other tables.
>
> eg:
>
> K_Nr Bundesland Bezirk Index.Branch
> 1 2 2 1,2,3
> 2 5 3 2,3
> 3 2 2 2
> 4 2 2 2,5,8
>
> etc.
Bad, bad bad bad bad.
1. This is the minor problem: You have a nonstandard character in the
"Index.Branch" filed, requiring you to take special precautions whenever you
query that field.
2. This is the major problem: You are storing multiple pieces of data in the
Index.Branch field, which is a violation of first normal form. It is this
violation that is causing your problem now.
What you have here is a "many-to-many" relationship between these two
tables. I.E. many records in the first table can be associated with/related
to many records in the branch table. The way to resolve this relationship is
through the use of a "bridge" table (other people have other names for this
type of table). In this case, the bridge table would look like this:
K_Nr Bundesland Bezirk Branch
1 2 2 1
1 2 2 2
1 2 2 3
2 5 3 2
2 5 3 3
etc.
This makes it possible to write queries without having to break up multiple
pieces of data in a single field.
Give it a try and see for yourself. And do yourself a favor: use only the
letters a-Z for your database object names.
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"