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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:31:27+00:00 2026-05-27T16:31:27+00:00

This is my table layout: — Table structure for table `areas` CREATE TABLE IF

  • 0

This is my table layout:

-- Table structure for table `areas`
CREATE TABLE IF NOT EXISTS `areas` (
  `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL,
  `country` varchar(20) NOT NULL,
  `city` varchar(20) NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- Table structure for table `matches`
CREATE TABLE IF NOT EXISTS `matches` (
  `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `user_id` bigint(20) unsigned NOT NULL,
  `view_id` bigint(20) unsigned NOT NULL,
  `status` enum('h','n') NOT NULL,
  `exp_date` date NOT NULL,
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

-- Table structure for table `users`
CREATE TABLE IF NOT EXISTS `users` (
  `ID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `limit_age` varchar(5) NOT NULL DEFAULT '18:30',
  `limit_gender` varchar(2) DEFAULT NULL,
  `notifications` int(11) NOT NULL DEFAULT '0',
  `name` varchar(30) NOT NULL,
  `email` varchar(40) NOT NULL,
  `image_big` varchar(120) NOT NULL,
  `image_small` varchar(120) NOT NULL,
  `crop_data` int(11) DEFAULT NULL,
  `visible` tinyint(1) NOT NULL DEFAULT '0',
  `age` int(11) DEFAULT NULL,
  `registered_at` datetime NOT NULL,
  `views` bigint(20) unsigned NOT NULL DEFAULT '0',
  `hots` bigint(20) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`ID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=15 ;

I will try to explain this better:

I have a given ID.
I would like to select one entry from users which is not the ID i have given
AND which user_id does not exist in matches
AND has visible = 1
AND where any country + city matches the given users country + city

Is this the correct way to do it (12 is an example of an given ID):

SELECT *
FROM users a
INNER JOIN areas ON areas.user_id = a.id
WHERE a.id NOT IN (SELECT user_id FROM matches)
AND NOT a.id = '12'
AND a.limit_age = '18:30'
AND a.visible = '1'
AND areas.country = 'sverige'
AND areas.city = 'gbg'

Sorry for the confusion 🙂

  • 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-27T16:31:28+00:00Added an answer on May 27, 2026 at 4:31 pm

    Ok, I’ll make an attempt at this:

    SELECT *
    FROM users a
    INNER JOIN areas ON areas.user_id = a.id
    WHERE a.id NOT IN (SELECT user_id FROM matches)
    AND a.visible = '1'
    AND a.limit_age = '18:30'
    AND a.limit_gender = 'f'
    AND areas.country = ?
    AND areas.city = ?;
    

    This is SELECTing from “users”, and returning a result only if that user also has an entry in the “areas” table. The first item in the WHERE clause ensures that a row will not be returned if the users.id (a.id) is found in the user_id field on the “matches” table. Next, I added checks for visible = 1, limit_age, and limit_gender as specified in his attempt. Finally, I left country and city parameterized so that they can be added as parameters in the php code. If anything that should give you a starting point.

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

Sidebar

Related Questions

I have a table with this layout: CREATE TABLE Favorites ( FavoriteId uuid NOT
I have this code to create table layout. In every row, had one OnclickListener
I have this big data-entry sort of page, a table kind of layout using
this table i want to create job_id dynamic Jobs Title text Job Description text
This table is used to store sessions (events): CREATE TABLE session ( id int(11)
Got this: Table a ID RelatedBs 1 NULL 2 NULL Table b AID ID
I'm trying to build a table layout similar to this --------------------------------------------------------------------- | 01.01.2010 01:00
If I have a table like this very very simple example: table { table-layout:fixed;
This is my code. <table id=addComments style=width:430px; table-layout:fixed; display:none; padding-right:3px; padding-left:3px;> <tr> <td colspan=3>
I came across this kind of table layout once upon a time (Unfortunately, I

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.