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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:44:45+00:00 2026-06-18T12:44:45+00:00

[1] SELECT X.id FROM somwhere WHERE X.location = _stringReturnedFromC#_ // I need ID from

  • 0
[1] SELECT X.id FROM somwhere WHERE X.location = _stringReturnedFromC#_
            // I need ID from this table, I only know strin: Location (from C#)

[2] SELECT Y.NameID FROM _relationBetweenXandY_ xy WHERE xy.ID = [1]
           // I use the ID I just found in [1]

[3] SELECT Z.Name FROM Z WHERE Z.NameID = [2]
           // I use the ID I found in [2]

Now how can I tell select [2] that I am looking for xy.ID = result from select [1]

And select [3] that I’m looking for the name of the guy with the ID Z.NameID

I asked this question here but as far as I’m concerned that question is beyond saving.

Z table: 
      Z.Name, Z.NameID
Y Table: 
      Y.PLACE, Y.PlaceID // fixed, Used to be PlaceID, is inface string: Place
X Table:
      X.Name, X.PlaceID

If they have the same name, they are foreign keys (NameID, PlaceID)

This is how the actual code looks like:

SELECT * FROM Angajati a
JOIN Distribuire d ON d.Locatie = 'Oradea'
// now I need to get d.DistribuireID while I know d.Locatie (d.location). How ?
JOIN Angajari an ON d.DistribuireID = an.DistribuireID

Thus

SELECT *
FROM TableX X 
   JOIN TableY y on x.PlaceId = y.PlaceId
   JOIN TableZ z on y.NameId = z.NameId

Does not work because I don’t know Y.PlaceID, I just know Y.Place

LAST EDIT

Sorry if this is getting too long. Here is how it should look like (what I mean by that, even if the syntax won’t work, this is the logic) Now I just need the syntax for this!

SELECT d.DistribuireID FROM Distribuire d WHERE d.Locatie = 'Oradea'
JOIN Angajari an ON an.DistribuireID = d.DistribuireID /*Here I'd need an.AngajatID for the locationID I just selected*/
JOIN Angajati a ON a.AngajatID = an.AngajatID
  • 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-06-18T12:44:46+00:00Added an answer on June 18, 2026 at 12:44 pm

    Looks like you just need some INNER JOINs:

    SELECT *
    FROM TableX X 
       JOIN TableY y on x.PlaceId = y.PlaceId
       JOIN TableZ z on y.NameId = z.NameId
    

    Hope this helps.

    -EDIT — Why won’t this work? Sorry if I’m not understanding your question…

    SELECT d.DistribuireID 
    FROM Distribuire d 
       JOIN Angajari an ON an.DistribuireID = d.DistribuireID
       JOIN Angajati a ON a.AngajatID = an.AngajatID
    WHERE d.Locatie = 'Oradea'
    

    Good luck.

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

Sidebar

Related Questions

I saw this example somewhere: rs = connection.prepareStatement(select * from table).executeQuery(); Could I use
I am comparing two table like this: SELECT * FROM tableA AS A INNER
I recall hearing or reading somewhere that SELECT * from TABLE where date >=
Somewhere in my application, I have a query: $sql = SELECT * FROM table
I have query like this: $sql = SELECT * FROM global_info WHERE title LIKE
SELECT * FROM Table JOIN Other ON Table.id = Other.tableId I'm structuring a MySQL
I have this code: $pages = $conn->prepare('SELECT * FROM pages WHERE slug = startpage');
The result is always 1: $sql = 'SELECT COUNT(Vote) FROM ' . $table; $res
I'd like my Windows Form ComboBox to only allow users to select from available
say I have this: select money from somewhere I want now another column called

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.