achievable with the means of SQL?
Hello,
same begin new topic:
Let 'playlist' be a sequence of images in a specified order. The items of the playlists are stored in a table like the following:
CREATE TABLE `playlist_items` (
`id` smallint(6) NOT NULL auto_increment,
`list_id` smallint(6) NOT NULL,
`display_id` smallint(6) NOT NULL,
`fs_path` text NOT NULL,
PRIMARY KEY (`id`),
KEY `display_index` (`list_id`,`display_id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
After the following query
SELECT display_id,fs_path FROM playlist_items WHERE list_id=123 AND display_id>=12 LIMIT 10;
I receive a result set like
+------------+-----------------------+
| display_id | fs_path |
+------------+-----------------------+
| 12 | /path/to/img12.jpg |
| 13 | /path/to/img13.jpg |
| 14 | /path/to/img14.jpg |
| 15 | /path/to/img15.jpg |
| 16 | /path/to/img16.jpg |
| 17 | /path/to/img17.jpg |
| 18 | /path/to/img18.jpg |
| 19 | /path/to/img19.jpg |
| 20 | /path/to/img20.jpg |
| 21 | /path/to/img21.jpg |
+------------+-----------------------+
Is there any means in SQL to specify a SQL query the returns the following result set from the table defined above?
+------------+-----------------------+-----------------------+
| display_id | fs_path | next |
+------------+-----------------------+-----------------------+
| 12 | /path/to/img12.jpg | /path/to/img13.jpg |
| 13 | /path/to/img13.jpg | /path/to/img14.jpg |
| 14 | /path/to/img14.jpg | /path/to/img15.jpg |
| 15 | /path/to/img15.jpg | /path/to/img16.jpg |
| 16 | /path/to/img16.jpg | /path/to/img17.jpg |
| 17 | /path/to/img17.jpg | /path/to/img18.jpg |
| 18 | /path/to/img18.jpg | /path/to/img19.jpg |
| 19 | /path/to/img19.jpg | /path/to/img20.jpg |
| 20 | /path/to/img20.jpg | /path/to/img21.jpg |
| 21 | /path/to/img21.jpg | /path/to/img22.jpg |
+------------+-----------------------+-----------------------+
Or in other words, are there means to reference a column in the recordset following a recordset?
I was thinking about that and did not find a solution which will solve the problem with using SQL only.
Subject
Written By
Posted
achievable with the means of SQL?
January 12, 2008 01:44PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.