Sagewire Logo

select from table

3 Message(s) by 3 Author(s) originally posted in mysql database


From: Patrick Date:   Thursday, July 12, 2007
Hi,

Can anyone show me how to do the following:

From a table I'd like to retrieve the following:

company and website s.

When I do a select on on this table i will 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'd 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.


From: David Ayres Date:   Saturday, July 14, 2007
wrote in message:
Hi,
Can anyone show me how to do the following:
From a table I'd like to retrieve the following:
company and websites.
When I do a select on on this table i will 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'd 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 would not make much sense or be useful (even if it
were possible). What are you doing with this data?

Dave


From: Captain Paralytic Date:   Monday, July 23, 2007
wrote in message:
Hi,
Can anyone show me how to do the following:
From a table I'd like to retrieve the following:
company and websites.
When I do a select on on this table i will 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'd 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 @xxxxxxxxxxx = '';
SELECT IF(@xxxxxxxxxxx=`company`,'',@xxxxxxxxxxx:=`company`) `company`,`website`
FROM `tab1`



Next Message: How'd you like 2 Million Sites linking to your ad ?


Blogs related to select from table

RE: SQL Plugin (created)
There are *{sql:dataSource=TestDS|table=false} select count(*) from test01 {sql}* rows in table test01. {sql:dataSource=TestDS|p1=%test%|showsql=true} select * from test01 where a1 like ? {sql} ...

Database Design #3: Table Joins
Associative Table mysql> select * from a_b; +------+------+ | a_id | b_id | +------+------+ | 1 | 1 | +------+------+ 1 row in set (0.00 sec). So in the sample data above I have three tables. The first table has two rows, ...

mysql> SELECT @id := cust_id FROM customers WHERE
The following statement determines the highest sum of the arms and legs columns in the limbs table and assigns it to the @max_limbs variable: mysql> SELECT @max_limbs := MAX(arms+legs) FROM limbs; Another use for a variable is to save ...

MySQL supports indian language character sets
Hi techies, this article is about how to store and manipulate multi languages in mysql table. May be useful while developing globalization / locale support enabled websites. MySQL Multi language support... By default mysql supports many ...

Portable Sequence Generation with MySQL
PRIMARY KEY(ID));. INSERT INTO TEST_SOURCE (ID) VALUES (NULL), (NULL), (NULL), (NULL), (NULL), (NULL); … will give us a TEST_SOURCE table with 6 auto-increment values. mysql> SELECT * FROM TEST_SOURCE; ...

MySQL Optimization Question about COUNT and SELECT
I have an index running on my varchar column in my table and was wondering if it is better to use the COUNT() function when selecting or to use SELECT LIMIT 1 if all I really need to do is see if the new data exists in the table already ...


Programming | Sports | Autos

copyright 2006
Valid XHTML 1.0 Transitional