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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T02:08:41+00:00 2026-06-18T02:08:41+00:00

The table is called limits and takes the following fields: id | ip |

  • 0

The table is called limits and takes the following fields:

id    |    ip    |    limit

on every page load, I’m checking if the user has a record in this table (determined by ip) and if they don’t, I insert a record. However if the record already exists, I don’t want to do anything.

I basically need a INSERT IF NOT EXISTS type query. I’ve already read this and the INSERT IGNORE example looks good but as far as I can tell it only works for primary keys. In my case the id field is the primary key and I want to check if the ip already exists.

Here’s some sort of pseudo SQL code:

INSERT INTO `limits` (ip, limit)
VALUES ('127.0.0.1', 8)
IF NOT EXISTS `limits`.`ip`

Thanks for any help!

EDIT: tried this too

INSERT IGNORE INTO `limits`
SET `ip` = ‘127.0.0.1′,
`limit` = 8;
  • 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-18T02:08:42+00:00Added an answer on June 18, 2026 at 2:08 am

    INSERT IGNORE will ignore any unique indexes, whether it’s the primary key or any unique key.

    You can create a unique key on IP using

    ALTER TABLE limits
      ADD CONSTRAINT idx_limits_ip
      UNIQUE (ip)
    

    The Manual has a few alternative syntax to create indexes.

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

Sidebar

Related Questions

I have a MySQL table called accounts . Within this table is a field
I am having a table called Tl which consists of fields ID,Name and Course.
I have a table called 'survey_product' with the following structure: id int(11) order_id int(11)
Problem In the following query, plr_stations is called twice: once to limit the WHERE
I have a table called Classes which stores information on College classes. It has
I have a MySQL database table called 'Videos' with only three columns (fields?): ID,
So, The situation is like this: I have one table called invoice, and it
I have a table called items. IN this table there are many columns. One
I have a database called gameschedules and a table called dec1212. Inside of this
Not sure what this is called so that limits my ability to search for

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.