Possible in SQL?

2006-05-22 Thread Jeremy Bunton
Hello, I have a table that looks something like this. Com1 genderfname lname 001 M Matt Smith 001 M Bill Wright 005 FKara Brown 005 M Mike White What I need

Re: Possible in SQL?

2006-05-22 Thread Jim Wright
You could do it with a subquery select * from sometable a WHERE a.gender = 'M' AND lname = (SELECT max(lname) FROM foo WHERE com1=a.com1) (of course, this assumes that lname is unique within a com1, which may not be the case...you may need to add on a identity field to make sure you only get

Re: Possible in SQL?

2006-05-22 Thread Jim Wright
fixing my query...I had used used foo as the tablename originally, and not changed it in both places... select * from sometable a WHERE a.gender = 'M' AND lname = (SELECT max(lname) FROM sometable WHERE com1=a.com1) -- Jim Wright Wright Business Solutions [EMAIL PROTECTED] 919-417-2257

RE: Possible in SQL?

2006-05-22 Thread Snake
May 2006 13:34 To: CF-Talk Subject: Possible in SQL? Hello, I have a table that looks something like this. Com1 genderfname lname 001 M Matt Smith 001 M Bill Wright 005 FKara Brown 005

RE: Possible in SQL?

2006-05-22 Thread Jeremy Bunton
: Monday, May 22, 2006 8:52 AM To: CF-Talk Subject: RE: Possible in SQL? I would have thought distinct would do what you want, are you sure you use dit correctly. Select distinct com1, gender, fname, lname FROM mytable WHERE gender = 'M' Group by com1, gender, fname, lname - Snake -Original

RE: Possible in SQL?

2006-05-22 Thread Dave Watts
I have a table that looks something like this. Com1 genderfname lname 001 M Matt Smith 001 M Bill Wright 005 FKara Brown 005 M Mike White What I

RE: Is this possible in SQL

2004-08-12 Thread Bryan Love
child may have peace'... - Thomas Paine, The American Crisis Let's Roll - Todd Beamer, Flight 93 -Original Message- From: Andy J [mailto:[EMAIL PROTECTED] Sent: Monday, August 09, 2004 4:22 PM To: CF-Talk Subject: Is this possible in SQL I have two tables which I want to query

Re: Is this possible in SQL

2004-08-10 Thread Andy Jarrett
Cheers Matt, Worked a charm I have two tables which I want to query at the same time. I'm thinking something along the lines of SELECT c.categoryid, sc.sub_CategoryId FROM categories c, sub_category sc WHERE c.category = '#form.searchVal#' OR sc.sub_Category = '#form.searchVal#' LIMIT 1 But

Is this possible in SQL

2004-08-09 Thread Andy J
I have two tables which I want to query at the same time. I'm thinking something along the lines of SELECT c.categoryid, sc.sub_CategoryId FROM categories c, sub_category sc WHERE c.category = '#form.searchVal#' OR sc.sub_Category = '#form.searchVal#' LIMIT 1 But where this is a left join it

RE: Is this possible in SQL

2004-08-09 Thread Matthew Walker
Have you tried union? SELECT. UNION SELECT. _ From: Andy J [mailto:[EMAIL PROTECTED] Sent: Tuesday, 10 August 2004 11:22 a.m. To: CF-Talk Subject: Is this possible in SQL I have two tables which I want to query at the same time. I'm thinking something along the lines of SELECT