select where "conditions" AND code.length == small

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

select where "conditions" AND code.length == small

Post by Luke »

I need to select from 3 tables where "some conditions" and table1.code is the least amount of characters. Is this possible?

To elaborate, I have products that can be in multiple categories, and I want to grab the category code out of the Product_Category relational table where the category code is the smallest. Thanks! :)
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

ORDER BY CHARACTER_LENGTH(foo)

?
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

nice
Post Reply