SQLite query to get data from multiple tables -


मेरे पास 4 टेबल हैं,

ModTable file_id, mod_flag

TrackTable artist_id album_id file_id शीर्षक

एल्बम लेबल album_id, एल्बम

कलाकारता

अब तक मैंने क्या किया है (छद्म कोड)

  1. SELECT file_id, artist_id, album_id, शीर्षक से TrackTable WHERE file_id IN (ModTable जहां से mod_flag = 1 का चयन करें file_id);   

चरम मामलों में, यह लगभग 30000 file_ids लौटाएगा इसलिए इन सभी file_ids के लिए,

  2. के लिए (int count = 0; count & lt; noOfRecords / * 30000 * /; count ++) कलाकार चुनें ArtistTable WHERE artist_id ==% llu का चयन एल्बम FROM उपरोक्त प्रश्न मेरे लिए काम करता है लेकिन मैं यह जानना चाहता था कि क्या इस को लागू करने का एक अनुकूलित तरीका है। क्या मुझे लूप के अंदर क्वेरीज़ से बचना चाहिए?   

सामान्य तौर पर आप नीचे की तरह तालिकाओं में शामिल होंगे इसका बेहतर प्रदर्शन होना चाहिए, क्योंकि क्वेरी को इंजन से अनुकूलित किया जा सकता है।

  SELECT t.file_id, t.artist_id, t.album_id, t.title, a.album, ar ट्रैकटैबल टी से एल्बम में जुड़ें। पर एक टी। एलएलबीम_आईडी = ए.एएलबीएम_आईड में शामिल करें ArtistTable में एआर t.artist_id = ar.artist_id WHERE t.file_id में (चयन करें file_id ModTable से कहां mod_flag = 1);    

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -