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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:36:16+00:00 2026-05-31T09:36:16+00:00

I am very new to SQL when I execute the below query it returns

  • 0

I am very new to SQL

when I execute the below query it returns the following results:

SELECT table1.image_name, table1.item_id
FROM table1, table2, table3
WHERE table2.catagory="item"
AND table3.account_id=59

image_name    image_id
-------------------------
d9.jpg      89
d9.jpg      89
d9.jpg      89
d9.jpg      89
d10.jpg      90
d10.jpg      90
d10.jpg      90
d10.jpg      90
etc.....

The results repeat the same attribute four times! I don’t understand why this is and I cannot find a reason for this anywhere!

I have 3 tables, table1 PK(image_id) is referenced as the FK in Item. Item PK(Item_id) is referenced with FK in table3. table3 has a compound key from table 4(account_id) and table2(item_id).

My query is clearly wrong, but I don’t understand why? I hope someone could provide an explanation to the result!, or help point me in the right direction!

Thanks

  • 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-31T09:36:18+00:00Added an answer on May 31, 2026 at 9:36 am

    You get multiple results because you do not specify join conditions. Foreign key relations are good, but you need to specify that they apply in your query:

    SELECT table1.image_name, table1.item_id
    FROM table1, table2, table3
    WHERE table2.catagory="item"
    AND table3.account_id=59
    AND table1.id = table2.item_id
    AND table2.item_id = table3.id
    

    Note the last two conditions. You need to change them to match your needs.

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

Sidebar

Related Questions

I have a LINQ to SQL query: from at in Context.Transaction select new {
Im very new to SQL but need to write a query to do the
Hi I'm very new to sql but have been passed a job in which
I'm very new to Sql, and having trouble wrapping my brain around the syntax.
I am very new to SQL and i need to retreive a number of
I am very new to sql.The actual problem is much bigger. I need information
I am very new to using SQL and I haven't been able to find
I am a very experienced MS Sql developer, and a few new job positions
I'm trying to return an XML file based on my query results. I'm very
I am new to SQL Server and created my very first stored procedure. It

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.