473,385 Members | 1,893 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Urgent problem - Resord Set

How do I select the First Record only based on MemberID

The layout is PhotoID,MemberID,Title

1, 666, blah1
2, 555, blah2
3, 666, blah3
4, 777, blah4
6, 777, blah5
7, 999, blah6
8, 444, blah7

So the result Im after is

1, 666, blah1
2, 555, blah2
4, 777, blah4
7, 999, blah6

Table is called TbPhoto (Using Access)
Jul 20 '05 #1
3 1422
I would do this via cursors, which is never good but.....what can you do.

Create a temp table.
define the cursor
fetch cursor
while status <> -1
if the 3-digit number is not in temp table
insert the record into temp table
fetch next
end while loop
SELECT * FROM temp_table

I assume that you also want 8, 444, blah7 should be in your
result set.

Oscar...

"Andrew" <an****@nospam.com> wrote in message
news:rF***************@newsfep1-gui.server.ntli.net...
How do I select the First Record only based on MemberID

The layout is PhotoID,MemberID,Title

1, 666, blah1
2, 555, blah2
3, 666, blah3
4, 777, blah4
6, 777, blah5
7, 999, blah6
8, 444, blah7

So the result Im after is

1, 666, blah1
2, 555, blah2
4, 777, blah4
7, 999, blah6

Table is called TbPhoto (Using Access)

Jul 20 '05 #2
Andrew (an****@nospam.com) writes:
How do I select the First Record only based on MemberID

The layout is PhotoID,MemberID,Title

1, 666, blah1
2, 555, blah2
3, 666, blah3
4, 777, blah4
6, 777, blah5
7, 999, blah6
8, 444, blah7

So the result Im after is

1, 666, blah1
2, 555, blah2
4, 777, blah4
7, 999, blah6

Table is called TbPhoto (Using Access)


SELECT PhotoID, MemberID, Title
FROM TbPhoto a
JOIN (SELECT PhotoID = MIN (PhotoID), MemberID
FROM TbPhoto
GROUP BY MemberID) AS B ON a.PhotoID = b.PhotoID
ORDER BY a.PhotoID
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #3
Do:

SELECT *
FROM tbl
WHERE PhotoId = (SELECT MIN(t1.PhotoId)
FROM tbl t1
WHERE t1.MemberId = tbl.MemberId);

--
-- Anith
( Please reply to newsgroups only )
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Rob | last post by:
I have a form - when you click the submit button, it appends a variable to the URL (e.g. xyz.cgi?inputID=some_dynamic_variable) It also opens a new page. Now, that some_dynamic_variable is...
9
by: Stefan Bauer | last post by:
Hi NG, we've got a very urgent problem... :( We are importing data with the LOAD utility. The input DATE field data is in the format DDMMYYYY (for days) and MMYYYY (for months). The target...
8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
28
by: Tamir Khason | last post by:
Follwing the struct: public struct TpSomeMsgRep { public uint SomeId;
16
by: | last post by:
Hi all, I have a website running on beta 2.0 on server 2003 web sp1 and I keep getting the following error:- Error In:...
7
by: zeyais | last post by:
Here is my HTML: <style> ..leftcolumn{float:left;width:300px;border: 1px solid #ccc} ..rtcolumn{float:left;width:600px;border: 1px solid #ccc} </style> <body> <div class="leftcolumn"...
33
by: dembla | last post by:
Hey Frnds can anyone help me in this i need a program in 'c' PROGRAM to print NxN Matrix 9 1 8 1 2 3 2 7 3 as 4 5 6 6 4 5 7 8 9 in sorted form
8
by: ginnisharma1 | last post by:
Hi All, I am very new to C language and I got really big assignment in my work.I am wondering if anyone can help me.........I need to port compiler from unix to windows and compiler is written...
3
by: N. Spiker | last post by:
I am attempting to receive a single TCP packet with some text ending with carriage return and line feed characters. When the text is send and the packet has the urgent flag set, the text read from...
7
by: Cirene | last post by:
I used to use the Web Deployment Project with my VS2005 projects. Now I've fully upgraded to VS2008. Do I have to download a new version of the Web Deployment Project? If so where can I find...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.