Re: need help with GROUP BY

2003-02-08 Thread Paul DuBois
At 9:24 -0600 2/5/03, Jaime Teng wrote:

I have a MySQL table:

++--+--+-+-++
| Field  | Type | Null | Key | Default | Extra  |
++--+--+-+-++
| id | int(10) unsigned |  | PRI | NULL| auto_increment |
| account| varchar(10)  |  | MUL | ||
| detail | text | YES  | | NULL||
++--+--+-+-++


I would like to perform a search,

SELECT id,account FROM tablename WHERE detail LIKE '%pattern%';

However, this would produce several hits for a single account.
I'd like it to produce only one hit *per* account and give me
id where '%pattern%' was found and account where it was found on.
It should only return *one* result per account.


Hmm...

Either I am not understanding what you are saying, or what you are
saying makes no sense: If there are two id values for a given account
that have detail values matching the pattern, which id do you want
it to display?



regards,
Jaime


sql, query

-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: need help with GROUP BY

2003-02-07 Thread Shapiro, David
DISTINCT?



-Original Message-
From: Tab Alleman [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, February 05, 2003 12:31 PM
To: Jaime Teng; [EMAIL PROTECTED]
Subject: RE: need help with GROUP BY 


SELECT id,account FROM tablename WHERE detail LIKE '%pattern%' GROUP BY
Account;

-Original Message-
From: Jaime Teng [mailto:[EMAIL PROTECTED]] 

I have a MySQL table:

...

It should only return *one* result per account.




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail
<[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: need help with GROUP BY

2003-02-06 Thread Frank Peavy
Jaime,
You should be using the DISTINCT function.
SELECT DISTINCT account, id, FROM etc.

This should give you one instant of 'account' in your SELECT output.



At 09:24 AM 2/5/03 +, Jaime Teng wrote:

I have a MySQL table:

++--+--+-+-++
| Field  | Type | Null | Key | Default | Extra  |
++--+--+-+-++
| id | int(10) unsigned |  | PRI | NULL| auto_increment |
| account| varchar(10)  |  | MUL | ||
| detail | text | YES  | | NULL||
++--+--+-+-++


I would like to perform a search,

SELECT id,account FROM tablename WHERE detail LIKE '%pattern%';

However, this would produce several hits for a single account.
I'd like it to produce only one hit *per* account and give me
id where '%pattern%' was found and account where it was found on.
It should only return *one* result per account.

regards,
Jaime



-
Before posting, please check:
   http://www.mysql.com/manual.php  (the manual)
   http://lists.mysql.com/  (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




Re: need help with GROUP BY

2003-02-06 Thread Frank Peavy
Jaime,
You should be using the DISTINCT function.
SELECT DISTINCT account, id, FROM etc.

This should give you one instant of 'account' in your SELECT output.



At 09:24 AM 2/5/03 +, Jaime Teng wrote:

I have a MySQL table:

++--+--+-+-++
| Field  | Type | Null | Key | Default | Extra  |
++--+--+-+-++
| id | int(10) unsigned |  | PRI | NULL| auto_increment |
| account| varchar(10)  |  | MUL | ||
| detail | text | YES  | | NULL||
++--+--+-+-++


I would like to perform a search,

SELECT id,account FROM tablename WHERE detail LIKE '%pattern%';

However, this would produce several hits for a single account.
I'd like it to produce only one hit *per* account and give me
id where '%pattern%' was found and account where it was found on.
It should only return *one* result per account.

regards,
Jaime



-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




-
Before posting, please check:
  http://www.mysql.com/manual.php   (the manual)
  http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php




RE: need help with GROUP BY

2003-02-06 Thread Tab Alleman
SELECT id,account FROM tablename WHERE detail LIKE '%pattern%' GROUP BY
Account;

-Original Message-
From: Jaime Teng [mailto:[EMAIL PROTECTED]] 

I have a MySQL table:

...

It should only return *one* result per account.




-
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/   (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php