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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:06:50+00:00 2026-05-27T00:06:50+00:00

I amy trying to build a statistics table for marketing issues for specific site

  • 0

I amy trying to build a statistics table for marketing issues for specific site :

currently I planning to build table like this

Source_IP    source_city    Destination_IP   destination_city 
127.0.0.1       NY           242.212.12.1         Paris
242.212.12.1   Paris           127.0.0.1           NY  

I want to prevent case like the above I.E the combination of (Source_ip , source_city) and (Destination_IP destination_city) should only be one record and not 2 how can i prevent this on sql?

  • 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-27T00:06:50+00:00Added an answer on May 27, 2026 at 12:06 am

    Assuming your DBMS allows function based indexes, the following would do the trick:

    CREATE UNIQUE INDEX idx_no_dupes 
        ON your_table (least(source_ip, destination_ip), greatest(source_ip, destination_ip));
    

    The use of least and greatest will always index the tuples in the “same order”, so it doesn’t matter which value is in which column.

    If your DBMS does not support least or greatest you will need to replace this with a CASE construct.

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

Sidebar

Related Questions

Suppose I have a table, Foo, that looks like this: ID | Name |
I am trying to use the qgraphicsview qgraphicsitem to create a scene like a
I am trying to add asynchronous output to a my program. Currently, I have
When trying to execute this query my mysql server cpu usage goes to 100%
I've been trying for days now to try and sort this out. Today was
I'm trying to pass elements from a list to a for loop and of
I am trying to use sqlite (sqlite3) for a project to store hundreds of
i got a problem once again :D a little info first: im trying to
I am trying to create an array for years which i will use in
I have a my views and controllers set up like so. A Tab/Bar controller

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.