Re: mysql question regarding distinct/group by...
SELECT * FROM Dog GROUP BY FooId HAVING FooId = 1; This should also work. On 1/5/07, ViSolve DB Team <[EMAIL PROTECTED]> wrote: Hi, > dog > fooID int > size int > id int > > dog > fooIDsizeid >1 2 1 >2 5 2 >1 5 3 > > if i do a query > select * from dog where fooID='1'; > > i get > 1,2,1 > 1,5,3 > Try, select * from dog where fooID=1 group by fooID; - which retrieves the first instance; resulting in, 1,2,1 Thanks ViSolve DB Team - Original Message - From: "bruce" <[EMAIL PROTECTED]> To: Sent: Thursday, January 04, 2007 6:07 AM Subject: mysql question regarding distinct/group by... > hi... > > i've asked something similar before.. but it appears something is going > wrong... so, back to basics... > > i have the following test tbl. > > dog > fooID int > size int > id int > > dog > fooIDsizeid >1 2 1 >2 5 2 >1 5 3 > > if i do a query > select * from dog where fooID='1'; > > i get > 1,2,1 > 1,5,3 > > how can i do a distinct/group by select such that if i do a select on > fooID=1, i'll only get '1,2,1', or '1,5,3', meaning that i don't get both > of > the items where fooId=1. > > thanks... > > > > -- > MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: > http://lists.mysql.com/[EMAIL PROTECTED] > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]
Re: mysql question regarding distinct/group by...
Hi, dog fooID int size int id int dog fooIDsizeid 1 2 1 2 5 2 1 5 3 if i do a query select * from dog where fooID='1'; i get 1,2,1 1,5,3 Try, select * from dog where fooID=1 group by fooID; - which retrieves the first instance; resulting in, 1,2,1 Thanks ViSolve DB Team - Original Message - From: "bruce" <[EMAIL PROTECTED]> To: Sent: Thursday, January 04, 2007 6:07 AM Subject: mysql question regarding distinct/group by... hi... i've asked something similar before.. but it appears something is going wrong... so, back to basics... i have the following test tbl. dog fooID int size int id int dog fooIDsizeid 1 2 1 2 5 2 1 5 3 if i do a query select * from dog where fooID='1'; i get 1,2,1 1,5,3 how can i do a distinct/group by select such that if i do a select on fooID=1, i'll only get '1,2,1', or '1,5,3', meaning that i don't get both of the items where fooId=1. thanks... -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
Re: mysql question regarding distinct/group by...
In the last episode (Jan 03), bruce said: > i've asked something similar before.. but it appears something is going > wrong... so, back to basics... > > i have the following test tbl. > > dog > fooID int > size int > id int > > dog > fooIDsizeid > 1 2 1 > 2 5 2 > 1 5 3 > > if i do a query > select * from dog where fooID='1'; > > i get > 1,2,1 > 1,5,3 > > how can i do a distinct/group by select such that if i do a select on > fooID=1, i'll only get '1,2,1', or '1,5,3', meaning that i don't get both of > the items where fooId=1. How about just asking for the first matching record with LIMIT 1? -- Dan Nelson [EMAIL PROTECTED] -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]
mysql question regarding distinct/group by...
hi... i've asked something similar before.. but it appears something is going wrong... so, back to basics... i have the following test tbl. dog fooID int size int id int dog fooIDsizeid 1 2 1 2 5 2 1 5 3 if i do a query select * from dog where fooID='1'; i get 1,2,1 1,5,3 how can i do a distinct/group by select such that if i do a select on fooID=1, i'll only get '1,2,1', or '1,5,3', meaning that i don't get both of the items where fooId=1. thanks... -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]