Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1081535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T22:10:52+00:00 2026-05-16T22:10:52+00:00

I want to insert a row of data into a table with five columns

  • 0

I want to insert a row of data into a table with five columns (this table joins members and games); four of the five columns are known, while the fourth, rank, has to be dynamically calculated:

wishlists(id (int, pk), memberid (int, FK), gameid(int, FK), rank (int), createdat(timestamp) )

INSERT INTO wishlists (memberid, gameid, rank)
VALUES (somememberid, somegameid, )

The value rank needs to search the table and find all the records belonging to a certain member, figure out the ranks, and insert the new record with the lowest rank.

rank = MAX(ISNULL(Rank,0))+1

I’ve tried a few variations, but I can’t get the syntax right. I know how to do it in two queries, but I can’t figure out how to do it in one query.

EDIT The following code, which I have used on a prior occasion, yields [Err] 1582 - Incorrect parameter count in the call to native function 'ISNULL'

insert into wishlists (memberid, gameid, rank)
select 
memberid, 
gameid, 
MAX(ISNULL(Rank,0))+1
from wishlists;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T22:10:52+00:00Added an answer on May 16, 2026 at 10:10 pm
    INSERT
    INTO    wishlists (memberid, gameid, rank)
    SELECT  @memberid, @gameid, COALESCE(MAX(rank), 0) + 1
    FROM    wishlists
    WHERE   memberid = @memberid
    

    Substitute your actual memberid and gameid in place of @-prefixed parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to insert data into a table, then if the table already has
Hi I want to insert into this kind of column family row with composite
I want to insert a row in a table, and when I do the
I want to insert a row into the Database using SqlDataAdapter. I've 2 tables
I am using the html table. I want to insert a new row to
I want to insert a record into a MySQL database table from a formulaire.
I made iPad application in which, I want to insert record into database table,
Whenver I try to insert a new row into my table manually, I get
I want to insert a new row into an Access database. I'm looking at
I am creating a program that is going to insert data into a table

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.