I don't know if this can be done purely in SQL.

Programmatically, you could do something like

SHOW COLUMNS FROM tablename LIKE "vector%";

That would give you the names (and types, which you can ignore) of the
desired columns. Then you can programmatically build up the list of columns.

Regards,

Jerry Schwartz
Global Information Incorporated
195 Farmington Ave.
Farmington, CT 06032

860.674.8796 / FAX: 860.674.8341


> -----Original Message-----
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
> Sent: Thursday, January 11, 2007 5:01 AM
> To: mysql@lists.mysql.com
> Subject: Select where the column names are not fully known
>
> We have a logging package that logs data into a table. Part
> of the data
> that is logged are elements of a vector. A logging application
> automatically takes out the elemets of the vector and automatically
> creates column names based on it's name and the element. This
> data will
> be mixed in with lots of other scalar data, but the elements will be
> created next to each other. For example, I may have a table
> with column
> names like this:
>
> datetime
> scalar1
> scalar2
> scalar3
> vector_1
> vector_2
> vector_3
> vector_4
> scalar4
> scalar5
>
> etc etc. I reality there is a lot more data than this. I neet
> to be able
> to select only the items of the vector - like this:
>
> select vector_1,vector_2,vector_4,vector_4 from mytable where
> datetime=somedatetime.
>
> So far so good. However the problem is that the vector size can vary
> from contract to contract. I don't want to have to change the select
> command for each contract we do. The format of the column
> name is always
> itemname_x where x starts at 0.
>
> So I'd like to do something like
>
> select vector_* from mytable where datetime=somedatetime.
>
> but of course this doesn't work.
>
> Anyone any ideas how I can do this?
>
>
> Andy
>
>




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to