dbTalk Databases Forums  

select from table

mailing.database.mysql mailing.database.mysql


Discuss select from table in the mailing.database.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Patrick
 
Posts: n/a

Default select from table - 07-12-2007 , 07:43 AM






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.



Reply With Quote
  #2  
Old   
David Ayres
 
Posts: n/a

Default Re: select from table - 07-14-2007 , 06:50 PM






On Jul 12, 8:43 am, Patrick <g... (AT) geen (DOT) nl> wrote:
Quote:
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



Reply With Quote
  #3  
Old   
Captain Paralytic
 
Posts: n/a

Default Re: select from table - 07-23-2007 , 07:48 AM



On 12 Jul, 13:43, Patrick <g... (AT) geen (DOT) nl> wrote:
Quote:
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`



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.