Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

The Database Forum


You are currently viewing our The Database Forum as a guest. Please register to participate.
Login



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

Posts: 32
Name: Eugene Sutula
Location: Ukraine
Trades: 0
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.
__________________

Please login or register to view this content. Registration is FREE

WebHive is offline
Reply With Quote
View Public Profile Visit WebHive's homepage!
 
 
Register now for full access!
Old 08-21-2007, 10:46 AM Re: How to get field information from SQL query
tripy's Avatar
Do not try this at home!

Posts: 3,621
Name: Thierry
Location: I'm the uber Spaminator !
Trades: 0
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");
__________________
Only a biker knows why a dog sticks his head out the window.
tripy is offline
Reply With Quote
View Public Profile Visit tripy's homepage!
 
Old 09-18-2007, 07:32 AM Re: How to get field information from SQL query
Experienced Talker

Posts: 44
Trades: 0
I also don't know much about it but i feel that the above code given by tripy should work.
__________________

Please login or register to view this content. Registration is FREE

Best Place to hunt for Code
codingmaster is offline
Reply With Quote
View Public Profile
 
Old 09-19-2007, 09:28 AM Re: How to get field information from SQL query
Experienced Talker

Posts: 44
Name: Kuldeep Sahi
Trades: 0
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%' "); 
__________________

Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE
,
Please login or register to view this content. Registration is FREE
Kuldeep2195 is offline
Reply With Quote
View Public Profile Visit Kuldeep2195's homepage!
 
Old 09-19-2007, 11:53 AM Re: How to get field information from SQL query
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
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!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 03-14-2008, 12:08 PM Re: How to get field information from SQL query
Novice Talker

Posts: 5
Trades: 0
try:

dim variable as string

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

Latest Blog Post:
Astounding Republican Paranoia
Posts: 5,662
Name: John Alexander
Trades: 0
If you were using SQL Server, you could put the cursor in the name of the table and hit ALT + F1.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Learning Newbie is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to How to get field information from SQL query
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.69643 seconds with 12 queries