Click to See Complete Forum and Search --> : Impossible?!
chrismartz
02-04-2006, 10:56 AM
I created a table called t_miles on my SQL 2000 server. I pull the variables schoolfrom and schoolto. Lets say I use the number 1 as schoolfrom and the number 5 as schoolto. How would I pull the number of miles the person is going from the table setup like the attached image. The number of miles that should be pulled is 5. Hopefully I explained this right!
chazzy
02-04-2006, 11:42 AM
hm
1-4 are the column names and 1-6 are the rownum's?
Does SQL server have a row seek function? how about using rownums?
chrismartz
02-04-2006, 05:52 PM
You are right about 1-4 are the column names and 1-6 are the rownum's. I do not know of a seek function.
chazzy
02-05-2006, 09:19 AM
Hmm
what about the rownum's? basically since you have no id for the row, there's really no way of grabbing it (using the row number's doesn't count).
you could create a view of the data though, to emulate an id if you wanted.
unless of course those 1-6 are actually in the table as data then it would just be
SELECT col1 FROM your_table WHERE id='5';
you'd have to change the syntax as needed for sql server, though. but honestly iw ouldn't consider your table a proper table without a primary key.
edit:
Did some searching on database journal and found this article
http://www.databasejournal.com/features/mssql/article.php/2244821
that describes a way to do it without having an id. its using temp tables. you could do a similar thing w/ a view as well though.