Selecting NEXT / PREVIOUS recurring item in a column

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Selecting NEXT / PREVIOUS recurring item in a column

Edmondo Borasio
*progr_no* *ID*
1 grace
*2* *john*
3 alan
4 tim
*5* *john*
*6* *john*
7 sandra
*8* *john*

What is the simplest and most efficient way of telling SQLITE to select the
NEXT or the PREVIOUS *progr_no *for a given recurring ID, let's say "john"?

Let's assume that I currently I am at progr_no=5.

I was thinking of maybe looping for a given ID and building an associative
array with also the progr_no, but there must be a more efficient and direct
solution, I guess!

Cheers

Ed
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Selecting NEXT / PREVIOUS recurring item in a column

Simon Slavin-3


On 6 Aug 2017, at 9:03pm, Edmondo Borasio <[hidden email]> wrote:

> *progr_no* *ID*
> 1 grace
> *2* *john*
> 3 alan
> 4 tim
> *5* *john*
> *6* *john*
> 7 sandra
> *8* *john*
>
> What is the simplest and most efficient way of telling SQLITE to select the
> NEXT or the PREVIOUS *progr_no *for a given recurring ID, let's say "john"?

Trying to understand this.  Are you saying that you start knowing "john" and want the program to produce NEXT = 6 ?  How should the program know which "john" you’re currently on ?

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Selecting NEXT / PREVIOUS recurring item in a column

Edmondo Borasio
Hi Simon,

Yes, you are correct. The program should get me to the previous one which
is 2 or the next one which is 6.
It know it because I have previously manually selected that particular one.

Regards,

Edmondo
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Selecting NEXT / PREVIOUS recurring item in a column

Richard Damon
In reply to this post by Edmondo Borasio
On 8/6/17 4:03 PM, Edmondo Borasio wrote:

> *progr_no* *ID*
> 1 grace
> *2* *john*
> 3 alan
> 4 tim
> *5* *john*
> *6* *john*
> 7 sandra
> *8* *john*
>
> What is the simplest and most efficient way of telling SQLITE to select the
> NEXT or the PREVIOUS *progr_no *for a given recurring ID, let's say "john"?
>
> Let's assume that I currently I am at progr_no=5.
>
> I was thinking of maybe looping for a given ID and building an associative
> array with also the progr_no, but there must be a more efficient and direct
> solution, I guess!
>
> Cheers
>
> Ed

Something like SELECT progr_no FROM table WHERE progr_no > 5 AND ID =
"john" ORDER BY progr_no ASC LIMIT 1

(I think that's correct, doing strictly from memory).

Not sure what the best index would be, probably an index on ID, progr_no
since ID needs an exact match

--
Richard Damon

_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Selecting NEXT / PREVIOUS recurring item in a column

Edmondo Borasio
Hi Richard. Thanks for the suggestion. It makes lots of sense but
unfortunately I am unable to test it.. Completely out of the blue yesterday
I got this error message and OpenSuse is no longer starting on VirtualBox
(Mac). Really weird because I didn't make any changes...
In the previous days it started giving me a blank screen and freezing when
it was idle. I have updated Mac OS and VB but nothing.

No valid rapl domain found in package 0.

Failed to start journal service

Do you have any idea by any chance of what it could be?


Cheers


Edmondo


--
Dr Edmondo Borasio, MedC BQ Ophth, FEBO
Consultant Ophthalmologist
Specialised in Cornea, Cataract & Laser Refractive Surgery

Head of Corneal and Refractive Surgery Department
Burjeel Hospital
Abu Dhabi, UAE
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Selecting NEXT / PREVIOUS recurring item in a column

Simon Slavin-3


On 7 Aug 2017, at 6:38am, Edmondo Borasio <[hidden email]> wrote:

> I am unable to test it.. Completely out of the blue yesterday
> I got this error message and OpenSuse is no longer starting on VirtualBox
> (Mac).

Can’t fix your problem but Macs come with the SQLite command line tool.  Get a Terminal prompt on the Mac and type "sqlite3".

> No valid rapl domain found in package 0.
>
> Failed to start journal service
>
> Do you have any idea by any chance of what it could be?


Try Googling your problem.

Simon.
_______________________________________________
sqlite-users mailing list
[hidden email]
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users
Loading...