Reply to Re: I need help with very complex query

Your name:

Reply:


Posted by David Haynes on 10/23/87 11:38

johnny wrote:
> hi all,
>
> I hope it is easier for you to answer than for me trying to explain
> it...
>
> In a database I have some tables , each one has some mandatory fields
> at the beginning and a couple at the end.
> In the middle each table can have some additional fields from 0 to n
> depending on how many fields have been inserted by who created the
> table.
>
> Now, I need to set up a script which ,after receiving from a form the
> table name, can print the first known fields,and all the additional
> ones , but I don' t want it to show the last 2 columns of the table
> because they store sensitive or useless contents.
>
>
> any tips ?
>
> TIA
>
> johnny
>
Sounds like you have a database design problem more than a query
problem. With the limited details you have provided, I would suggest
something like the following:

1. have a table that contains the mandatory fields and the private ones.
Let's call this one table 'A'.
2. make sure that each row in the table has a unique id (in mysql, look
at the auto_increment feature)
3. create a second table, 'B', that will contain the arbitrary data.
Each row in B will contain the argument value and the id from the row in
table A that is relates to. So, you have 0 to n rows in B referencing
the unique id of a row in A.

This lets you have an arbitrary number of fields in B for each entry in
A. Also, if you name the columns in A in your SQL query instead of
using '*', you can have SQL ignore the private fields on the end.

If this helps, I would suggest you spend a little time looking at
database design and the capabilities of the SQL language.

-david-

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация