Jump to content
Server Maintenance This Week. ×

4 Table SQL Search


This topic is 2346 days old. Please don't post here. Open a new topic instead.

Recommended Posts

I am still learning SQL and I was hoping for some help to add another relationship to my equation.

I would like the SQL to show me all the ItemsIDs that are assigned to selected years (via key) that are originated from Details table layout.

This is working good, but it's showing my ALL ItemsID meeting that year criteria, but I would like to only see __ItemsID based off the layout I am on, which is Details.

I think I need to add FROM "\Details\" and WHERE _fkDetailsID = ? ; Details::__DetailsID, but I am struggling to add in another table!!

Any help would be greatly appreciated to get where I am going or simplify!!

 

 

Details::__DetailsID <-> Items::_fkDetailsID 

                         Items::__ItemsID <-> AssignedYears::_fkItemID

                                              AssignedYears::_fkYearID <-> Years::__YearsID
Let (

[

Key = 8  // YearsID from Dropdown

] ;

ExecuteSQL( "

SELECT \"_fkItemsID\"

FROM \”AssignedYears\” INNER JOIN \”Years\"  

ON \”AssignedYears\ . \"_fkYearsID\" = \"Years\" . \”__YearsID\"

WHERE \”AssignedYears\ . \"_fkYearsID\" = ?

ORDER BY \"_fkYearsID\" ASC "

; " " ; "" ; Key )

    )

 

Edited by shredded
Link to comment
Share on other sites

Your graph doesn't match your SQL -- fkItemsID vs. fkItemID , fkyearsID vs. fkyearID -- so first thing is double check the field names are correct.

It doesn't look like you need a join. You're selecting a field from AssignedYears, querying a field from AssignedYears, and sorting by a field in AssignedYears. All same table.

Link to comment
Share on other sites

This topic is 2346 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.