Re: small query prob in Mysql
| From: | Wouter van Vliet | Date: | Tue, 14 Sep 2004 12:16:07 +0000 |
| Subject: | Re: small query prob in Mysql | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-196613@lists.php.net to get a copy of this message | ||
On Tue, 14 Sep 2004 05:37:30 +0000, Curt Zirzow
<php-general@zirzow.dyndns.org> wrote:
> * Thus wrote Sagar C Nannapaneni:
>
>
> > Hi everybody,
> >
> > I'm having a database named "items", inthat
> > one field name is "itemname" and the contents of
> > that field is as follows....
> >
> > Monitor 15" - LG
> > Monitor 17" - Samsung
> > Keyboard - TVS
> > Monitor 15" - Samsung
> > Mouse - Genius
> > Keyboard - Microsoft
> > ....
> > ....
> > The first part is the component name and the second is the Company name
> > I need to have the distinct components in this field...like this
> >
> > Monitor
> > Keyboard
> > Mouse
> >
> > Any help would b greatly appreciated....
>
> In order to do that properly, you would need a normalized database,
> a properly flattened data structure or hacked with some string
> manipulation. Seek more help from a SQL or mysql list.
>
> Curt
> --
> The above comments may offend you. flame at will.
>
Little handson: there is a way of selecting a certian part of a field,
for instance everything till the first occurance of a space or dash.
Probably two ways even, one with regexes the other one with substr
kinda calls - all directly requestable to mysql.
though I'd follow Curt's advice if i were you, take two columns, or
even three - components, specifications, brand .. or smth.