Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
246 views
in Technique[技术] by (71.8m points)

sql - How To Select All Rows In A Table By Querying Data In Another Table

I have 3 SQLite tables that must be queried to obtain the final data.

I must select everything in ItemAppearance where DisplayType == 4
Then take the corresponding number from the ID field and
Select all rows in ItemModifiedAppearance where ItemAppearanceID == Previous Number
Then take the corresponding number ItemID field and
Select all rows in ItemSearchName where ID == Previous Number
Finally, I can retrieve a large list of all the Display_lang values that I need.

Graphically: enter image description here

What's the best / fastest / most efficient way to get this list of strings?

question from:https://stackoverflow.com/questions/65623546/how-to-select-all-rows-in-a-table-by-querying-data-in-another-table

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Your question is a bit confusing, but I'm guessing here join is your friend:

SELECT *
FROM ItemAppearance ia LEFT JOIN 
     ItemModifiedAppearance im
     ON ia.ID==im.ItemAppearanceID JOIN
     ItemSearchName isn
     ON ia.ID==isn.ID
WHERE ia.DisplayType = 4;

So that just gets all 3 databases, where all the id's match, but only the ones that are in ItemAppearance that are of DataType 4.

Hopefully that helps, or makes sense, or was even in the ballpark of your question. Let me know.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...