Connecting Tech Pros Worldwide Forums | Help | Site Map

Next row value

Newbie
 
Join Date: Aug 2009
Posts: 12
#1: Aug 26 '09
Hello,

Here is my question to you guys.

Having a list of items for example:

Table Fruits
Name Description
Apple sweet
Orange round
Mango ripe

I queried:
select *
from Fruits
where description like 'sweet'

My result is:

Name Description
Apple sweet


My problem scenario is I would like to add another column from the result above and I would like to name that column Fruit2 and I would like to have the value of column Fruit2 the next row value which is orange..

The way I would want the result would be like this:

Name Description Fruit2
Apple sweet orange



Thanks in advance.

code green's Avatar
Expert
 
Join Date: Mar 2007
Location: England
Posts: 1,083
#2: Aug 26 '09

re: Next row value


Quote:
I would like to have the value of column Fruit2 the next row value
"Next row" is a meaningless concept in databases.
If this is really what you want to do then you will need an extra column in your table called 'row_number'

You need to think outside the flat file design and decide what it is you are trying to achieve.
Yes, it is possible to get 'The next row' but the DB engine will decide what is the next row.
Nothing to do with the table entries.
Reply