Re: MySQL Result

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As a kind soul pointed out, I missed the string joining you need to do, so I 
feel tasked with addressing this further.. 

Simple answer: I don't see a way to do this with a single query unless you're 
using a DB with subqueries.. in which case you might be able to figure 
something out, but without a server to try this on, I can't say for sure. 

You could however break it down into two queries and use PHP to patch the data 
together:

query1: get the make/model
query2: get the years

That type of thing.. Hope that helps.
-Micah 


On Sunday 06 March 2005 06:18 pm, Micah Stevens wrote:
> Just reorder your list of selected fields.
>
> SELECT <fieldnames in order to be returned> from <tablename> WHERE
> <requirements>
>
> -Micah
>
> On Sunday 06 March 2005 01:10 pm, Wendell Frohwein wrote:
> > Hello all,
> >
> > Have a question for you, don't know how simple this is. I want the
> > output that mysql sends to arranged a certain way and I don't know if it
> > is possible.
> >
> > Here is the select statement:
> >
> > SELECT cart_search.id, cart_search.year, cart_makes.thename as makename,
> > cart_models.thename as modelname, cart_versions.thename as versionname
> > FROM cart_search, cart_makes, cart_models, cart_versions WHERE
> > cart_search.rand='PYYKjQFXRBa3PkYMpsnY' AND
> > cart_makes.id=cart_search.make AND cart_models.id=cart_search.model AND
> > cart_versions.id=cart_search.version ORDER BY cart_makes.thename,
> > cart_models.thename, cart_search.year;
> >
> > cart_search.rand='PYYKjQFXRBa3PkYMpsnY' is what I use to call up a group
> > to a specified product.
> >
> > Here is the output from above:
> >
> > +----+------+----------+-----------+-------------+
> >
> > | id | year | makename | modelname | versionname |
> >
> > +----+------+----------+-----------+-------------+
> >
> > |  9 | 1992 | Acura    | Integra   | RS          |
> > | 10 | 1993 | Acura    | Integra   | RS          |
> > |  1 | 1994 | Acura    | Integra   | GSR         |
> > |  2 | 1995 | Acura    | Integra   | GSR         |
> > |  3 | 1996 | Acura    | Integra   | GSR         |
> > |  4 | 1997 | Acura    | Integra   | GSR         |
> > |  5 | 1998 | Acura    | Integra   | GSR         |
> > |  6 | 1999 | Acura    | Integra   | GSR         |
> > |  7 | 2000 | Acura    | Integra   | GSR         |
> > |  8 | 2001 | Acura    | Integra   | GSR         |
> >
> > +----+------+----------+-----------+-------------+
> >
> >
> > I wanted to know if it would be possible for it to output it like so:
> >
> > +----------+-----------+-------------+----------------------+
> >
> > | makename | modelname | versionname |        years         |
> >
> > +----------+-----------+-------------+----------------------+
> >
> > | Acura    | Integra   | RS          | 92,93                |
> > | Acura    | Integra   | GSR         | 94,95,96,97,98,99,01 |
> >
> > +----------+-----------+-------------+----------------------+
> >
> >
> > Thank you all once again for your help.
> >
> >
> > -Wendell Frohwein

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux