| Author |
Topic |
|
amodi
Yak Posting Veteran
83 Posts |
Posted - 2010-01-09 : 09:37:21
|
| Hello Friends, I want to sequence the records of one table based on another table. For example: Table A has 7 seven records(it can vary)as follows:TableA_ColumnA125545667Now there is another table B basically i contains less or same number of records as Table A.TableB_ColumnA661275Now i want the Table B record sequence to be arrange as of table A as follows:TableB_ColumnA125667Thanks. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-01-09 : 09:53:23
|
This is not a sequence that you can get using ORDER BY.So is there another column to get this order? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
amodi
Yak Posting Veteran
83 Posts |
Posted - 2010-01-09 : 09:55:44
|
quote: Originally posted by webfred This is not a sequence that you can get using ORDER BY.So is there another column to get this order? No, you're never too old to Yak'n'Roll if you're too young to die.
No there is no other column. Can we do it using conditions and loops as i am using stored procedure? |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-01-09 : 10:02:47
|
You can get the values without ORDER BY from a table but the outcoming sequence (i.e. order) is not reliable!select tb.columnAfrom tableA as taright join tableB tbon ta.ColumnA = tb.ColumnAwhere tb.ColumnA is not null No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-09 : 10:06:42
|
| Please note that there's no concept of first and last in sql table so sequence doesnt make sense unless you define in terms of a column . |
 |
|
|
amodi
Yak Posting Veteran
83 Posts |
Posted - 2010-01-09 : 10:07:25
|
| Is there any alternative, i want the sequence(i.e. order) to be reliable???Thanks webfred. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-01-09 : 10:08:47
|
I see no chance without having a column to define the order by. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
amodi
Yak Posting Veteran
83 Posts |
Posted - 2010-01-09 : 10:20:01
|
| Hello Visakh16, I have an asp.net application that mostly behaves like a book(or manual). database table has hundred of records that contains the text of the manual. So when the end user clicks "next" on a web page, data should be retrieved accordingly. Every thing is working fine. Now the problem some users don't have access to certain chapters. So when the user clicks the "next" on a web page, data should be retrieved based on permissions he/she has.Thanks. |
 |
|
|
amodi
Yak Posting Veteran
83 Posts |
Posted - 2010-01-09 : 10:22:13
|
| Thanks webfred |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-01-09 : 10:22:40
|
then pagenumbers sequence 1,2,5,66,7 makes no sense. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-09 : 10:28:36
|
quote: Originally posted by amodi Hello Visakh16, I have an asp.net application that mostly behaves like a book(or manual). database table has hundred of records that contains the text of the manual. So when the end user clicks "next" on a web page, data should be retrieved accordingly. Every thing is working fine. Now the problem some users don't have access to certain chapters. So when the user clicks the "next" on a web page, data should be retrieved based on permissions he/she has.Thanks.
are you using sql 2005? |
 |
|
|
amodi
Yak Posting Veteran
83 Posts |
Posted - 2010-01-09 : 10:32:12
|
| yes sql 2005 and stored procedures. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-01-09 : 10:35:25
|
| ok. can you give sample data from table storing permission details and also table containing page details of book |
 |
|
|
|