Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
Education
SQL JOIN QUERY
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="Superman_99" data-source="post: 19865420" data-attributes="member: 556480"><p><span style="font-size: 15px">මම කියලා දෙන්න යන්නෙ SQL JOIN QUERY ගැන, මේගැන හොඳටම දන්න අයත් ඇති, නොදන්න අයත් අතිකියල හිතුන නිසයි මෙහෙම POST එකක් දාන්න හිතුනෙ.<img src="/styles/default/xenforo/smilies/default/cool.gif" class="smilie" loading="lazy" alt=":cool:" title="Cool :cool:" data-shortname=":cool:" /> මේ පොස්ට් එකෙන් උබලට ගන්න දෙයක් තියේවි කියල විශ්වාස කරනවා.</span> </p><p></p><p><span style="font-size: 15px">SQL JOIN use වෙන්නෙ table දෙකක් හෝ ඊට වැඩි ගනනක rows එකට සම්බන්ද කිරීම සඳහායි.</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">එ කියන්නෙ අපි database එකක් හදනකොට අපිට අවශ්ය tables වෙන වෙනම තියාගන්නව Example එකක් විදිහට මෙහෙම හිතමු. </span></p><p></p><p><strong><span style="font-size: 15px">Orders Table</span></strong></p><p></p><p><img src="http://i.imgur.com/lVjrvLz.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p><strong><span style="font-size: 15px">Customers Table</span></strong></p><p></p><p><img src="http://i.imgur.com/iI13UjG.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p></p><p><span style="font-size: 15px">අපට තියනව Orders කියල table එකක්, තව අපට තියනව Customers කියල table එකක්, ok දැන් අපට ඕනි Customers ල දාන Orders ටික හොයගන්ඩ.</span></p><p><span style="font-size: 15px">එතකොට කොහොමද අපි එක හොය ගන්නෙ? මොකද Orders තියෙන්නෙ එක table එකක,</span></p><p><span style="font-size: 15px">Customers ල ඉන්නෙ තව එකක,ඔන්න මේවගේ අවස්තා වලදි තමයි අපට SQL JOIN ඕනි වෙන්නෙ.</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">හරි දැන් වැඩේට බහිමු. <img src="/styles/default/xenforo/smilies/default/cool.gif" class="smilie" loading="lazy" alt=":cool:" title="Cool :cool:" data-shortname=":cool:" /></span></p><p><span style="font-size: 15px"></span></p><p><strong><span style="font-size: 18px">SQL INNER JOIN</span></strong></p><p></p><p><span style="font-size: 15px">INNER JOIN එක තමයි SQL වලදී වැඩිපුරම use වෙන්නෙ. මේ JOIN එක use කරල අපට පුලුවන් condition එක TRUE වෙන අවස්තවල table දෙකක හෝ ඊට වැඩි ගනනක ඇති සියලුම ROWS return කරගන්න.</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">ok ... තෙරුනේ නැති අයට මේ example එක බැලුවහම තේරෙයි.</span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">Example එකක් විදිහට මේ sql query එක ගමු.</span></p><p></p><p><span style="color: RoyalBlue"><span style="font-size: 15px">SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate</span></span></p><p><span style="color: RoyalBlue"><span style="font-size: 15px">FROM Orders</span></span></p><p><span style="color: RoyalBlue"><span style="font-size: 15px">INNER JOIN Customers</span></span></p><p><span style="color: RoyalBlue"><span style="font-size: 15px">ON Orders.CustomerID=Customers.CustomerID;</span></span></p><p></p><p><span style="font-size: 15px">මඤ්ඤන් වගේද? <img src="/styles/default/xenforo/smilies/default/confused.gif" class="smilie" loading="lazy" alt=":confused:" title="Confused :confused:" data-shortname=":confused:" /></span></p><p><span style="font-size: 15px">ok මම කියලදෙන්නම්. <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">මෙහෙමයි. </span></p><p><span style="font-size: 15px">හොඳට බලන්ඩ Orders Table එක, ඒ Table එකේ තියනව CustomerID කියල column එකක්. මෙන්න මේ CustomerID කියන්නෙ Orders Table එකේ foreign key එක, ඒවගේම එක Customers Table එක primary key එක.</span></p><p></p><p><strong><span style="font-size: 15px">Orders Table</span></strong></p><p></p><p><img src="http://i.imgur.com/xcJC1Oz.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p><strong><span style="font-size: 15px">Customers Table</span></strong></p><p></p><p><img src="http://i.imgur.com/HsarSY6.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p><span style="font-size: 15px">හරි ඔන්න එතකොට අපේ කොල්ලන්ට ගැටළුවක් එනවා මොන මගුලක්ද මේ primary key එක foreign key එක කියන්නෙ කියල. <img src="/styles/default/xenforo/smilies/default/baffled.gif" class="smilie" loading="lazy" alt=":baffled:" title="Baffled :baffled:" data-shortname=":baffled:" /></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">හරි ඉන්ඩකෝ එකත් කියල දෙන්ඩ... <img src="/styles/default/xenforo/smilies/default/cool.gif" class="smilie" loading="lazy" alt=":cool:" title="Cool :cool:" data-shortname=":cool:" /></span></p><p><span style="font-size: 15px">මෙහෙමයි <img src="/styles/default/xenforo/smilies/default/growl.gif" class="smilie" loading="lazy" alt=":growl:" title="Growl :growl:" data-shortname=":growl:" /></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">PRIMARY KEY එක කියන්නෙ table එකක තියන ROWS uniquely identify කරගන්ඩ use කරන value එකක්. හරියට ඔයාගේ ID එකේ number එකවගේ ඒ number එක unique. හරි දැන් අනික. <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /></span></p><p><span style="font-size: 15px">FOREIGN KEY එක කියන්නෙ වෙනත් table එකක PRIMARY KEY එකක් කියන්ඩ පුළුවන්, හරියට මේවගේ මම ළඟ තියනව ඔයාගේ ID number එක, එකෙන් මට පුළුවන් වෙනවා ඔයාව අදුරගන්න. අපේ table දෙකට අනුවනම් Orders කියන table එකේ තියන CustomerID එකෙන් පුළුවන් ඊට අදාළ Customers table එකේ row එක හොයාගන්ඩ. හරි දැන් එ දෙකත් ok. <img src="/styles/default/xenforo/smilies/default/happy.gif" class="smilie" loading="lazy" alt=":)" title="Happy :)" data-shortname=":)" /></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">මම අයෙ පාඩමට එනව. අපි කියකියහිටියේ.. <img src="/styles/default/xenforo/smilies/default/nerd.gif" class="smilie" loading="lazy" alt=":nerd:" title="Nerd :nerd:" data-shortname=":nerd:" /></span></p><p><span style="font-size: 15px"></span></p><p><span style="font-size: 15px">හොඳට බලන්ඩ Orders Table එක, ඒ Table එකේ තියනව CustomerID කියල column එකක්. මෙන්න මේ CustomerID කියන්නෙ Orders Table එකේ foreign key එක, ඒවගේම එක Customers Table එක primary key එක. එතකොට අපට පුළුවන් INNER JOIN එක බවිතකරලා Orders Table එකේ තියන CustomerID වලටත් Customers Table එකේ තියන CustomerID සමානවන records ටික ඔක්කොම return කරගන්ඩ.</span></p><p></p><p><span style="font-size: 15px">අපේ query එකට අනුව මේවගේ result එකක්තමයි එන්නෙ.</span> <img src="/styles/default/xenforo/smilies/default/yes.gif" class="smilie" loading="lazy" alt=":yes:" title="Yes :yes:" data-shortname=":yes:" /></p><p></p><p><strong><span style="font-size: 15px">Result</span></strong></p><p></p><p><img src="http://i.imgur.com/lVjrvLz.jpg" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p></p><p></p><p><span style="font-size: 15px">හරි සරලව ඕක තමයි SQL INNER JOIN කියන්නෙ. </span></p><p><span style="font-size: 15px">SQL වල තවත් JOIN වර්ග කිහිපයක් තියනව එවතමයි..</span></p><p><span style="font-size: 15px"> INNER JOIN</span></p><p><span style="font-size: 15px"> LEFT JOIN</span></p><p><span style="font-size: 15px"> RIGHT JOIN</span></p><p><span style="font-size: 15px"> FULL JOIN</span></p><p><span style="font-size: 15px">ඒවා ගැනත් කියල දෙන්නම් දවසක.</span></p><p></p><p><span style="font-size: 15px"><span style="color: Red">එහෙනම් කස්ටියටම ජයවේවා.....!!</span></span></p></blockquote><p></p>
[QUOTE="Superman_99, post: 19865420, member: 556480"] [SIZE="4"]මම කියලා දෙන්න යන්නෙ SQL JOIN QUERY ගැන, මේගැන හොඳටම දන්න අයත් ඇති, නොදන්න අයත් අතිකියල හිතුන නිසයි මෙහෙම POST එකක් දාන්න හිතුනෙ.:cool: මේ පොස්ට් එකෙන් උබලට ගන්න දෙයක් තියේවි කියල විශ්වාස කරනවා.[/SIZE] [SIZE="4"]SQL JOIN use වෙන්නෙ table දෙකක් හෝ ඊට වැඩි ගනනක rows එකට සම්බන්ද කිරීම සඳහායි. එ කියන්නෙ අපි database එකක් හදනකොට අපිට අවශ්ය tables වෙන වෙනම තියාගන්නව Example එකක් විදිහට මෙහෙම හිතමු. [/SIZE] [B][SIZE="4"]Orders Table[/SIZE][/B] [img]http://i.imgur.com/lVjrvLz.jpg[/img] [B][SIZE="4"]Customers Table[/SIZE][/B] [img]http://i.imgur.com/iI13UjG.jpg[/img] [SIZE="4"]අපට තියනව Orders කියල table එකක්, තව අපට තියනව Customers කියල table එකක්, ok දැන් අපට ඕනි Customers ල දාන Orders ටික හොයගන්ඩ. එතකොට කොහොමද අපි එක හොය ගන්නෙ? මොකද Orders තියෙන්නෙ එක table එකක, Customers ල ඉන්නෙ තව එකක,ඔන්න මේවගේ අවස්තා වලදි තමයි අපට SQL JOIN ඕනි වෙන්නෙ. හරි දැන් වැඩේට බහිමු. :cool: [/SIZE] [B][SIZE="5"]SQL INNER JOIN[/SIZE][/B] [SIZE="4"]INNER JOIN එක තමයි SQL වලදී වැඩිපුරම use වෙන්නෙ. මේ JOIN එක use කරල අපට පුලුවන් condition එක TRUE වෙන අවස්තවල table දෙකක හෝ ඊට වැඩි ගනනක ඇති සියලුම ROWS return කරගන්න. ok ... තෙරුනේ නැති අයට මේ example එක බැලුවහම තේරෙයි. Example එකක් විදිහට මේ sql query එක ගමු.[/SIZE] [COLOR="RoyalBlue"][SIZE="4"]SELECT Orders.OrderID, Customers.CustomerName, Orders.OrderDate FROM Orders INNER JOIN Customers ON Orders.CustomerID=Customers.CustomerID;[/SIZE][/COLOR] [SIZE="4"]මඤ්ඤන් වගේද? :confused: ok මම කියලදෙන්නම්. :) මෙහෙමයි. හොඳට බලන්ඩ Orders Table එක, ඒ Table එකේ තියනව CustomerID කියල column එකක්. මෙන්න මේ CustomerID කියන්නෙ Orders Table එකේ foreign key එක, ඒවගේම එක Customers Table එක primary key එක.[/SIZE] [B][SIZE="4"]Orders Table[/SIZE][/B] [img]http://i.imgur.com/xcJC1Oz.jpg[/img] [B][SIZE="4"]Customers Table[/SIZE][/B] [img]http://i.imgur.com/HsarSY6.jpg[/img] [SIZE="4"]හරි ඔන්න එතකොට අපේ කොල්ලන්ට ගැටළුවක් එනවා මොන මගුලක්ද මේ primary key එක foreign key එක කියන්නෙ කියල. :baffled: හරි ඉන්ඩකෝ එකත් කියල දෙන්ඩ... :cool: මෙහෙමයි :growl: PRIMARY KEY එක කියන්නෙ table එකක තියන ROWS uniquely identify කරගන්ඩ use කරන value එකක්. හරියට ඔයාගේ ID එකේ number එකවගේ ඒ number එක unique. හරි දැන් අනික. :) FOREIGN KEY එක කියන්නෙ වෙනත් table එකක PRIMARY KEY එකක් කියන්ඩ පුළුවන්, හරියට මේවගේ මම ළඟ තියනව ඔයාගේ ID number එක, එකෙන් මට පුළුවන් වෙනවා ඔයාව අදුරගන්න. අපේ table දෙකට අනුවනම් Orders කියන table එකේ තියන CustomerID එකෙන් පුළුවන් ඊට අදාළ Customers table එකේ row එක හොයාගන්ඩ. හරි දැන් එ දෙකත් ok. :) මම අයෙ පාඩමට එනව. අපි කියකියහිටියේ.. :nerd: හොඳට බලන්ඩ Orders Table එක, ඒ Table එකේ තියනව CustomerID කියල column එකක්. මෙන්න මේ CustomerID කියන්නෙ Orders Table එකේ foreign key එක, ඒවගේම එක Customers Table එක primary key එක. එතකොට අපට පුළුවන් INNER JOIN එක බවිතකරලා Orders Table එකේ තියන CustomerID වලටත් Customers Table එකේ තියන CustomerID සමානවන records ටික ඔක්කොම return කරගන්ඩ.[/SIZE] [SIZE="4"]අපේ query එකට අනුව මේවගේ result එකක්තමයි එන්නෙ.[/SIZE] :yes: [B][SIZE="4"]Result[/SIZE][/B] [img]http://i.imgur.com/lVjrvLz.jpg[/img] [SIZE="4"]හරි සරලව ඕක තමයි SQL INNER JOIN කියන්නෙ. SQL වල තවත් JOIN වර්ග කිහිපයක් තියනව එවතමයි.. INNER JOIN LEFT JOIN RIGHT JOIN FULL JOIN ඒවා ගැනත් කියල දෙන්නම් දවසක.[/SIZE] [SIZE="4"][COLOR="Red"]එහෙනම් කස්ටියටම ජයවේවා.....!![/COLOR][/SIZE] [/QUOTE]
Insert quotes…
Verification
Dahaya deken beduwama keeyada?
Post reply
Top
Bottom