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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:47:45+00:00 2026-05-27T07:47:45+00:00

Scenario: We have 5 users. (users table) Each user has up to 10 imgs.

  • 0

Scenario:

We have 5 users. (users table)
Each user has up to 10 imgs. (image table)
These 10 images can be ordered 1 – 10. (image table)
Each img can be listed in multiple categories (say there are 5 categories – birds, bees, bunnies, brains, belugas (category table connected to img table via table that stores img_ids and category_ids)

In searching through the categories, say someone chooses bees. The search should find the images in that category that is listed CLOSEST to the #1 img for all users. So if each user has 3 images in the bees category, ordered as numbers 4, 7 & 9, the search should show the 4th as its closest to the number 1.

The results I keep getting are all over the place and almost seems like it is choosing the images via WHEN they were added to the DB.

SELECT i.img_name, i.ordered, a.user_name, c.keyword, c.cat_id
FROM images AS i JOIN artists AS a USING (user_id) 
JOIN img_cat_table AS im USING ( img_id )
JOIN catkeys AS c USING (cat_id)
WHERE ( cat_id = 3) // THE BEES ID # 
    GROUP BY user_id ORDER BY user_name DESC
  • 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-27T07:47:46+00:00Added an answer on May 27, 2026 at 7:47 am

    I’m also not sure if you want to show all of the relevant images in the right order, or only the top one. Assuming that it is the latter situation, you will need to join to a subquery or view that returns the min rank for each user, category:

    SELECT i.img_name, i.ordered, a.user_name, c.keyword, c.cat_id
    FROM images AS i JOIN artists AS a USING (user_id) 
    JOIN img_cat_table AS im USING ( img_id )
    JOIN catkeys AS c USING (cat_id)
    JOIN (
    SELECT user_id, min(img_rank) img_rank
    FROM images AS i 
    JOIN artists AS a on i.user_id = a.user_id
    JOIN img_cat_table AS im on im.img_id = i.img_id
    JOIN catkeys AS c on c.cat_id = i.cat_id
    WHERE ( cat_id = 3) ) x on x.user_id = a.user_id and x.img_rank = img_rank
    WHERE c.cat_id = 3
    

    I’m not sure what the name of the column that holds the image ranking is. I called it img_rank. Hopefully this will give you the idea

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

Sidebar

Related Questions

I have one scenario in which the user can define the column and that
Scenario : I have a users table in my application. I also have two
I have 2 tables - an Account table and a Users table. Each account
I have a scenario where there is an apartment and each apartment has flats
Here's the scenario: I have 2 tables: CREATE TABLE dbo.API_User ( id int NOT
Here's the scenario: We have users login on a secure connection. Could an unathorized
Here's the scenario: You have a Windows server that users remotely connect to via
I have a scenario where users of my ASP.NET web application submit testimonials consisting
I have the following scenario: I have various user's data stored in my database.
I have a scenario where a user will have access to a one-time-url. When

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.