Reply
How to get field information from SQL query
Old 08-21-2007, 09:23 AM How to get field information from SQL query
WebHive's Avatar
Experienced Talker

Posts: 32
Name: Eugene Sutula
Location: Ukraine
An hour ago run into a problem with mysql.
I have a table with few fields, some of them are SET type like
fruit SET('apple', 'lemon', 'banana')

How can I get 'apple', 'lemon', 'banana' from SQL query knowing name of field?
Will it be fine to use such sql query in production script?

Thanks in advance.
__________________
Custom Web Development
WebHive is offline
Reply With Quote
View Public Profile Visit WebHive's homepage!
 
When You Register, These Ads Go Away!
Old 08-21-2007, 09:46 AM Re: How to get field information from SQL query
tripy's Avatar
Fetchez la vache!

Posts: 2,054
Name: Thierry
Location: In the void
Never tried it, but maybe with http://www.php.net/manual/en/functio...field-type.php
or, as the comments suggest:
Code:
 $result = mysql_query("SHOW FIELDS FROM table.db");
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Old 09-18-2007, 06:32 AM Re: How to get field information from SQL query
Experienced Talker

Posts: 44
I also don't know much about it but i feel that the above code given by tripy should work.
__________________
www.coderewind.com
Best Place to hunt for Code
codingmaster is offline
Reply With Quote
View Public Profile
 
Old 09-19-2007, 08:28 AM Re: How to get field information from SQL query
Experienced Talker

Posts: 44
Name: Kuldeep Sahi
The query given by tripy will give you all the fields.

Since you know the field name, you can use LIKE to limit it to that field only.

PHP Code:
 $result mysql_query("SHOW FIELDS FROM table.db LIKE '%pattern%' "); 
Kuldeep2195 is offline
Reply With Quote
View Public Profile Visit Kuldeep2195's homepage!
 
Old 09-19-2007, 10:53 AM Re: How to get field information from SQL query
chrishirst's Avatar
Super Moderator

Posts: 13,519
Location: Blackpool. UK
actually the OP is trying to get the possible values for the SET (or enum)

SHOW COLUMNS FROM table LIKE 'ColumnName' ;

and in the Type column returned from that query you should find "set('val1','val2',val3')
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-14-2008, 11:08 AM Re: How to get field information from SQL query
Novice Talker

Posts: 5
try:

dim variable as string

variable=recordname.fields!Value
ludmila is offline
Reply With Quote
View Public Profile
 
Old 03-14-2008, 01:27 PM Re: How to get field information from SQL query
Learning Newbie's Avatar
Moderator

Latest Blog Post:
My Wish for Webmaster Talk
Posts: 5,181
Name: John Alexander
If you were using SQL Server, you could put the cursor in the name of the table and hit ALT + F1.
__________________
4 ways to improve the lives of the "bottom billion"

"HEY YOU KIDS GET OFF MY LAWN!" -John McCain
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to get field information from SQL query
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14382 seconds with 12 queries