0

hey..

i have a table with one column defined as SET
somethin like (a,b,c)

does anybody know the sql query to be run inorder to get elements like
a
b
c
all seperately so as to save it in an array in php script..??

2
Contributors
1
Reply
2
Views
7 Years
Discussion Span
Last Post by Atli
0

Hey.

I don't know of a MySQL statement that is capable of fetching those values in such a way that it can be return as a table, and I am unable to find one in the manual. (Although, it may well have eluded my brief search.)

Usually, the structure of a database is not dynamic, so columns defined as SET or ENUM would have fixed values, eliminating the need to actually read them out of the database. They could just be hard-coded into the front-end, as they should never actually change.

If the values of your SET column are supposed to be dynamic, you really shouldn't be using that type. Only data is supposed to be dynamic, not the structure of the database. You would probably be best of removing said SET column, creating a table for these values and using a N:M relationship to link them to the original table.

However, if you for some reason want to use a dynamic table structure (which I highly recommend against), then you could have PHP read the values from your SET column using the SHOW COLUMNS command.
See this blog for example.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.