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

  • Home
  • SEARCH
  • 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 8723615
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:40:03+00:00 2026-06-13T07:40:03+00:00

since you can’t auto increment two columns what would the Query be to get

  • 0

since you can’t auto increment two columns what would the Query be to get the last row of the table and +1 value of the column to insert a new row.

For example I have a table named players

looking abit like this:

id    player_id    player_name
 1      15           name1
 2      16           name2
 3      17           name3

I’m trying to make an admin panel to create a player from a form, the column ‘id’ auto increments but I also need player_id to increment too, but id and player_id are not the same as each other.

A query similar to this (I made this up so you can understand a little better)

$sql="select top 1 * from `players`  order by id desc";
$result =mysql_query($sql);
while ($data=mysql_fetch_assoc($result)){
    $playerid=$data['player_id'];
    Insert into `players` (`player_id`,`player_name`) VALUE ('$playerid' + '1', 'name4');

}
  • 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-06-13T07:40:04+00:00Added an answer on June 13, 2026 at 7:40 am

    Try This Code:

        $sql="SELECT player_id FROM `players` ORDER BY id DESC LIMIT 1";
        $result =mysql_query($sql);
        while ($data=mysql_fetch_assoc($result)){
            $playerid=$data['player_id']+1;
           }
    mysql_query("Insert into `players` (`player_id`,`player_name`) VALUES ('".$playerid."','name4')");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Since Postgres can only add columns at the end of tables, I end up
Since we can query on the XML file from C# (.NET), why do we
since I can't get CEDET to work for automatic code-completion (aka intelli-sense in the
What am I doing wrong in my code here since I can't get the
I would like to have some geek advice here since I can’t brainstorm more.
Since you can call the the Soundcloud API via XHR (because of the CORS
Since I can't put up a screenshot of my storyboard, I'll try to explain:
The following code gives a NullReferenceException since XPathSelectElement can't navigate through the XPath expression
In C++, since you can have class-instances as members in structs, the compiler has
I'm having trouble roating an image around itself using Canvas. Since you can't rotate

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.