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 1006909
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:32:12+00:00 2026-05-16T08:32:12+00:00

I have a table entity called position. I am storing the value using smallint(2)

  • 0

I have a table entity called position. I am storing the value using smallint(2) datatype, where I intend to store the value from 0 to 9 (max). I want to make sure the value is just a single integer and an integer should not be repeated at any cost. There should be a unique value assigned to each id of the position entity in the table ranging from 0 to 9. How do I achieve it? Is there any mysql syntax for that?

I am using MySQL with PHP.

here is the mysql table could someone add me the unique code and show

CREATE TABLE `advertisements` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(255) NOT NULL,
`position` smallint(2) NOT NULL,
`active` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

is this the correct syntax?

CREATE TABLE `advertisements` (
`id` int(11) NOT NULL auto_increment,
`title` varchar(255) NOT NULL,
`position` smallint(2) NOT NULL UNIQUE,
`active` tinyint(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
  • 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-16T08:32:12+00:00Added an answer on May 16, 2026 at 8:32 am

    You must define that column as UNIQUE.

    ALTER TABLE `a` ADD UNIQUE (
        `id`
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 507k
  • Answers 507k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use request_module to load a module May 16, 2026 at 3:54 pm
  • Editorial Team
    Editorial Team added an answer If you are doing this on the main UI thread,… May 16, 2026 at 3:54 pm
  • Editorial Team
    Editorial Team added an answer I'd always prefer what's (in order of importance from most… May 16, 2026 at 3:54 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have this entity class, called Pagina and I want to update the entry
I have a table in mysql called advertisements, in which there is an entity
I'm using Hibernate/JPA and have an @Entity object called Order, pointing at a MySQL
Let's say that I have a class/table called Images that, as it stands right
I have an entity called Pupil, and an entity called Loan. The Pupil entity
I have an entity called User which can have a list of other Users
For example, lets say I have an entity called user and an entity called
Overview: I'm designing a restaurant management application, and I have an entity called Order
suppose i have a entity called USER and a relationship FRIENDSHIP exist between two
I have a class hierarchy like this: @Entity @Table (name=call_distribution_policies) @Inheritance (strategy=InheritanceType.JOINED) public class

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.