Click here to get back home

select from table

 HomeNewsGroups | Search | About
 mailing.database.mysql    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
select from table Patrick 07-12-2007
`--> Re: select from table Captain Paralyt...07-23-2007
Posted by Patrick on July 12, 2007, 8:43 am
Please log in for more thread options
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.



Posted by David Ayres on July 14, 2007, 7:50 pm
Please log in for more thread options
> 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


Posted by Captain Paralytic on July 23, 2007, 8:48 am
Please log in for more thread options
> 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`


Similar ThreadsPosted
need help - select from one table where desn't exists in (select from another table where status=1) September 20, 2006, 8:34 pm
update [table] select - but I only need part of the column field value to select January 26, 2006, 2:38 pm
update from select in same table December 7, 2005, 5:31 pm
How to make a select statement FROM A TABLE that has two INDEXES ? December 20, 2005, 9:12 am
Reference to Table Alias in From Clause to be Used by Subquery in Select Clause October 12, 2006, 2:09 pm
Why does 'SELECT * FROM countries' truncate characters and 'SELECT country FROM countries' does not ? December 7, 2005, 5:42 am
MySQL table suddenly disappeared and a func table was created April 2, 2007, 1:04 am
I need to move column field values from one database table to another database table January 27, 2006, 1:15 pm
SELECT with MAX July 23, 2005, 9:30 am
Which SELECT is better? May 18, 2006, 12:48 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap