Link to home
Start Free TrialLog in
Avatar of fskilnik
fskilnikFlag for Brazil

asked on

value of field in position n

Hi there,

Let´s say I have a table XYZ with 2 fields and 3 records, say:

field1   field2
1               car
32             dog
123           cat

I want to select 'cat' with an SQL statement like:

"select field2  from tableXYZ where field1 = [value of field1 in n-row] order by field1 asc"

My question is: how should I "fill the bold place", please?

(I want  a general solution to this case, in which I am able to find which is the number present in the record of field1 when we are looking at the n-th row, where n is given.)

Thanks,
fskilnik.
Avatar of UnifiedIS
UnifiedIS

What do you mean the "nth" row?  is n the value of field1?  I'm guessing not but if so, it would just be n for your bold area:
select field2  from tableXYZ where field1 =n order by field1 asc

If n refers to an ID column in your table it would work like this
select field2  from tableXYZ where ID = n
Avatar of fskilnik

ASKER

The problem refers to your second interpretation (of course), but your suggestion does not work, because there is NO "ID" column with this name, although I WANT to do what you suggested... in other words, the problem is how to use the number of the line if the counter óf the number of the line involved is not a field itself... I hope you understood my difficulty.
ASKER CERTIFIED SOLUTION
Avatar of fskilnik
fskilnik
Flag of Brazil image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ah, and therein lies the problem with EE.  My effort is provided without cost to EE or the poser of the question.
@UnifiedIS: I am really surprised with your complaint, because I have been here at EE for many many years and your first reply showed me you took VERY little time even to understand my question (in my opinion), what is something ENORMOUSLY UNUSUAL in my EE experience, by the way.

(Sometimes I would like to give 5,000 points to the experts, not only the 500 permitted. It was certainly not the case here, simply because I could see no use to the "solution" you have provided.)

Even so, if you would like to (and if the moderator agrees), I would be glad to give you the 500 points as a compensation to your effort (your word, no pun-intended).
(I guess I found the solution myself.)