SearchSearch   

select from table

 
   Webmaster Forums (Home) -> MySQL RSS
Next:  User defined variables question  
Author Message
Patrick

External


Since: Jul 12, 2007
Posts: 1



(Msg. 1) Posted: Thu Jul 12, 2007 2:43 pm
Post subject: select from table
Archived from groups: mailing>database>mysql (more info?)

Hi,

Can anyone show me how to do the following:

From a table I would like to retrieve the following:

company and websites.

When I do a select on on this table i'll get

company 1 - website 1
company 1 - website 2
company 1 - webiste 3

company 2 - website 1
company 2 - website 2

etc.
But what I would like is:

company 1 website 1
website 2
website 3

company 2 website 1
website 2

etc.

Now I use the following select statement:
$query="select company, domainname from DOMAIN, CLIENT_PERSONAL_DATA,
USER where DOMAIN.idclient = CLIENT_PERSONAL_DATA.id";

Regards, Patrick.
Back to top
David Ayres

External


Since: Jul 14, 2007
Posts: 1



(Msg. 2) Posted: Sat Jul 14, 2007 4:50 pm
Post subject: Re: select from table
Archived from groups: per prev. post (more info?)

On Jul 12, 8:43 am, Patrick <g....DeleteThis@geen.nl> wrote:
> Hi,
>
> Can anyone show me how to do the following:
>
> From a table I would like to retrieve the following:
>
> company and websites.
>
> When I do a select on on this table i'll get
>
> company 1 - website 1
> company 1 - website 2
> company 1 - webiste 3
>
> company 2 - website 1
> company 2 - website 2
>
> etc.
> But what I would like is:
>
> company 1 website 1
> website 2
> website 3
>
> company 2 website 1
> website 2
>
> etc.
>
> Now I use the following select statement:
> $query="select company, domainname from DOMAIN, CLIENT_PERSONAL_DATA,
> USER where DOMAIN.idclient = CLIENT_PERSONAL_DATA.id";
>
> Regards, Patrick.

Patrick,

IMHO, that dataset wouldn't make much sense or be useful (even if it
were possible). What are you doing with this data?

Dave
Back to top
Captain Paralytic

External


Since: Jul 23, 2007
Posts: 103



(Msg. 3) Posted: Mon Jul 23, 2007 5:48 am
Post subject: Re: select from table
Archived from groups: per prev. post (more info?)

On 12 Jul, 13:43, Patrick <g... DeleteThis @geen.nl> wrote:
> Hi,
>
> Can anyone show me how to do the following:
>
> From a table I would like to retrieve the following:
>
> company and websites.
>
> When I do a select on on this table i'll get
>
> company 1 - website 1
> company 1 - website 2
> company 1 - webiste 3
>
> company 2 - website 1
> company 2 - website 2
>
> etc.
> But what I would like is:
>
> company 1 website 1
> website 2
> website 3
>
> company 2 website 1
> website 2
>
> etc.
>
> Now I use the following select statement:
> $query="select company, domainname from DOMAIN, CLIENT_PERSONAL_DATA,
> USER where DOMAIN.idclient = CLIENT_PERSONAL_DATA.id";
>
> Regards, Patrick.

Try:
SET @head = '';
SELECT IF(@head=`company`,'',@head:=`company`) `company`,`website`
FROM `tab1`
Back to top
Display posts from previous:   
       Webmaster Forums (Home) -> MySQL
Page 1 of 1

 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum