contact Posted August 28, 2007 Share Posted August 28, 2007 I have a list of student exam points and i wanna order them by using temporary table. Simply i use this code to do: insert into sm_temp select ' ' as id, sno from deneme order by puan desc The select statement works well if it's alone. But when i wanna use with INSERT, there's no error, but the order is wrong. For ex. the biggest point may gey number 1, the second may get 8, and the 3rd may get 59... How can i solve it? (It works well in Delphi with MSSQL.) Link to comment https://forums.phpfreaks.com/topic/67037-insert-select-problem/ Share on other sites More sharing options...
fenway Posted August 28, 2007 Share Posted August 28, 2007 I don't see why you're doing this at all... and what do you "care" what ID each record gets? Link to comment https://forums.phpfreaks.com/topic/67037-insert-select-problem/#findComment-336581 Share on other sites More sharing options...
contact Posted August 29, 2007 Author Share Posted August 29, 2007 I don't see why you're doing this at all... and what do you "care" what ID each record gets? I have thousands of records of an exam results for each student. I must give them an queue value. (And of course the highest point will get number 1, the second point will get number 2, etc.) The temp table has 2 fields: id: auto_increment, integer and primary sno: integer I wanna select the id as blank and sno from table "deneme" and wanna add them on the order of puan (desc). After adding all records to temp in order, i will update the all records' queue to temp's id by using temp's sno. Link to comment https://forums.phpfreaks.com/topic/67037-insert-select-problem/#findComment-337292 Share on other sites More sharing options...
fenway Posted August 29, 2007 Share Posted August 29, 2007 I gess you could use a user variable and increment it that way.... Link to comment https://forums.phpfreaks.com/topic/67037-insert-select-problem/#findComment-337300 Share on other sites More sharing options...
Illusion Posted August 30, 2007 Share Posted August 30, 2007 ..............order by NULL,puan desc; Link to comment https://forums.phpfreaks.com/topic/67037-insert-select-problem/#findComment-337642 Share on other sites More sharing options...
fenway Posted August 30, 2007 Share Posted August 30, 2007 ..............order by NULL,puan desc; ???? Link to comment https://forums.phpfreaks.com/topic/67037-insert-select-problem/#findComment-338016 Share on other sites More sharing options...
contact Posted September 2, 2007 Author Share Posted September 2, 2007 Problem continues... Link to comment https://forums.phpfreaks.com/topic/67037-insert-select-problem/#findComment-339809 Share on other sites More sharing options...
fenway Posted September 4, 2007 Share Posted September 4, 2007 Problem continues... Did you try using a user variable to keep a counter as previously suggested? Link to comment https://forums.phpfreaks.com/topic/67037-insert-select-problem/#findComment-341541 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.