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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:18:02+00:00 2026-05-23T19:18:02+00:00

I am stuck and I am trying to find a solution, so please help!

  • 0

I am stuck and I am trying to find a solution, so please help!

I have 3 tables:

Books (id, title, ...)

Authors (id, name, surname, ...)

book_authors (bookID, authorID, whatisdoing)

Now I want to retrieve all books depending on the title (user search) and all the other info (author name, surname). But, I want the book titles to be unique with only the first occurrence of the book_authors.whatisdoing to be shown.

In MS Access I achieved that with first function, but now first does not work and with min I didn’t get the results I want.

Any help would be appreciate.

The query in Access was:

SELECT 
    First(book_authos.whatisdoing) AS FirstOfidiothta_ID, 
    First(authors.name) AS onoma, 
    First(authors.surname) AS eponymo, 
    books.ID, books.title, books.photoLink
FROM (books 
INNER JOIN book_authors ON books.ID = book_authors.book_ID) 
INNER JOIN authors ON book_authors.author_ID = authors.ID 
GROUP BY 
    books.ID, books.titlos, books.photoLink, books.active 
HAVING 
    (((books.titlos) Like '%" & textString & "%') AND 
    ((books.active)=True) AND ((First(authors.active))=True)) 
ORDER BY 
    First(book_authos.whatisdoing), books.title
  • 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-23T19:18:04+00:00Added an answer on May 23, 2026 at 7:18 pm

    EDIT: Changed based on OP comments.
    EDIT 2: Revised to correct flaws.

    You might give this a try.

    SELECT aba.name, aba.surname, aba.whatisdoing,
        b.ID, b.title, b.photoLink
    FROM Books b
    JOIN
        (
        SELECT ba.bookID, ba.whatisdoing, a.name, a.surname,
          ROW_NUMBER() OVER (PARTITION BY ba.bookID ORDER BY ba.whatisdoing) AS sequence
        FROM book_authors ba
        JOIN Authors a ON ba.authorID = a.id
        WHERE a.active = 1
        ) AS aba ON b.id = aba.bookID
    WHERE b.title LIKE '%' + @textString + '%'
        AND b.active = 1
        AND aba.sequence = 1
    

    The ROW_NUMBER function assigns a row number to the row based on the groups defined in the PARTITION BY clause and the order defined by the ORDER BY clause.

    @textString is a SQL Server variable. I’m not sure how you would assign this in your situation.

    The boolean data type is BIT in SQL Server and the values are 0 for false and 1 from true.

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

Sidebar

Related Questions

I've got stuck in a problem with gflags when trying to find some memory
I've been stuck trying to arrive at a best solution for this for a
Sorry if a solution exists anywhere else, but I couldn't find one. I have
I've been stuck trying to figure out why a counter cache on my (parent)
Sometimes I still get stuck trying to translate procedural code into functional code. Is
I'm stuck trying to get a WinInet HTTP POST via SSL using ONLY C.
I'm stuck trying to get a regex to match a filetype in a sorting
I'm kind of like stuck trying to implement YUI autocomplete textbox. here's the code:
I am putting together a dynamic photo gallery and getting stuck trying to place
Really stuck on trying to write code to unzip a file or directory on

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.