Why are you storing a list of numbers in a varchar field?

If you were trying to associate attribtures of a product with attributes in other 
tables, then you should be using index tables.

For example:

PRODUCTS                        
id_product      product_name
1               t-shirt
2               baseball hat
3               sweater

COLORS          
id_color        color_name              
1               white
2               black
3               red

PRODUCTS_TO_COLORS
id_product      id_color
1               1
1               2
2               3
3               2

Creating this index table would be basically the thing as having a products table with 
a varchar field for colors as I suspect you have it setup:

PRODUCTS
id_product      product_name    product_colors
1               t-shirt         1,2
2               baseball hat    3
3               sweater         2

So why, you might ask, do you use another table to create the relationships?  Well, 
becuase it's proper datbase design.  You keep the numbers numbers and in doing so 
maintain the query and processing speed.  Whenver you convert a datatype to or from 
text, you're going to cause headaches for yourself.

---mark
        
--------------------------------------------------------------
Mark Warrick
Phone: (714) 547-5386
Efax.com Fax: (801) 730-7289
Personal Email: [EMAIL PROTECTED]
Personal URL: http://www.warrick.net 
Business Email: [EMAIL PROTECTED]
Business URL: http://www.fusioneers.com
ICQ: 346566
--------------------------------------------------------------


> -----Original Message-----
> From: Joel Firestone [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, June 27, 2000 6:04 AM
> To: [EMAIL PROTECTED]
> Subject: Selecting one number from a list
> 
> 
> Everyone:
> 
> I'm having a complete brain fart, so hopefully you guys can help.
> 
> I have a table with a varchar field named catid. When a url variable named
> catid is passed, the page grabs all the data for that specific 
> catid. Simple
> stuff.
> 
> My problem lies in now I need for the catid to be a list 
> (2,5,56,89). Thus the
> varchar field, and not a numeric. How can I select those items 
> that contain
> the correct url.catid? I tried the IN keyword, with no success.
> 
> Any help would be greatly appreciated.
> 
> Joel
> 
> 
> ------------------------------------------------------------------
> ------------
> Archives: http://www.eGroups.com/list/cf-talk
> To Unsubscribe visit 
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf
> _talk or send a message to [EMAIL PROTECTED] with 
> 'unsubscribe' in the body.

------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebarRsts&bodyRsts/cf_talk or send a message 
to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to