SET datatype

Reply

Join Date: Oct 2009
Posts: 5
Reputation: jyotidagia is an unknown quantity at this point 
Solved Threads: 0
jyotidagia jyotidagia is offline Offline
Newbie Poster

SET datatype

 
0
  #1
Nov 2nd, 2009
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..??
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 438
Reputation: Atli is on a distinguished road 
Solved Threads: 56
Atli's Avatar
Atli Atli is offline Offline
Posting Pro in Training
 
0
  #2
34 Days Ago
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.
Please do not ask for help in a PM. Use the forums.
And use [code] tags!
Reply With Quote Quick reply to this message  
Reply

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC