Jump to content

"insert ... select" problem


contact

Recommended Posts

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.