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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.