# Join Multiple table

**URL:** <https://forum.codewithmosh.com/t/join-multiple-table/17264>\
**Category:** SQL\
**Created:** [December 27, 2022, 5:14am UTC](https://forum.codewithmosh.com/t/join-multiple-table/17264 "2022-12-27T05:14:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruofanj](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@ruofanj](https://forum.codewithmosh.com/u/ruofanj)\
**Post date:** [December 27, 2022, 5:14am UTC](https://forum.codewithmosh.com/t/join-multiple-table/17264/1 "2022-12-27T05:14:38Z")

</div>

Hi everyone! I am having troubles with joining multiple tables. I write exactly the same code as video, but the result providing as descending order of order\_id instead of ascending. Could anyone please tell me why? Thank a lot!

 ![Screenshot 2022-12-27 at 12.14.26 AM](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/0/0db2926937ade663abfcc7a139704df17a74e830.png)

---

<div class="post-metadata">

**Author:** ![karu](https://avatars.discourse-cdn.com/v4/letter/k/3da27b/32.png) [@karu](https://forum.codewithmosh.com/u/karu)\
**Post date:** [December 27, 2022, 5:50am UTC](https://forum.codewithmosh.com/t/join-multiple-table/17264/2 "2022-12-27T05:50:35Z")

</div>

order status shud be ascending or order id?

---

<div class="post-metadata">

**Author:** ![ruofanj](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@ruofanj](https://forum.codewithmosh.com/u/ruofanj)\
**Post date:** [December 27, 2022, 4:28pm UTC](https://forum.codewithmosh.com/t/join-multiple-table/17264/3 "2022-12-27T16:28:09Z")

</div>

The order id should be ascending. In the video, the result show below

 ![Screenshot 2022-12-27 at 11.27.45 AM](https://us1.discourse-cdn.com/flex020/uploads/codewithmosh/original/2X/a/ac0defca14869df69122faa8efcc52a58e802538.png)

---

<div class="post-metadata">

**Author:** ![sajan](https://avatars.discourse-cdn.com/v4/letter/s/5e9695/32.png) [@sajan](https://forum.codewithmosh.com/u/sajan)\
**Post date:** [December 27, 2022, 7:04pm UTC](https://forum.codewithmosh.com/t/join-multiple-table/17264/4 "2022-12-27T19:04:52Z")

</div>

Hi,  
Add in the end of the query with below clause ,then it will work.  
ORDER BY o.order\_id

---

<div class="post-metadata">

**Author:** ![ruofanj](https://avatars.discourse-cdn.com/v4/letter/r/c68b51/32.png) [@ruofanj](https://forum.codewithmosh.com/u/ruofanj)\
**Post date:** [December 27, 2022, 7:14pm UTC](https://forum.codewithmosh.com/t/join-multiple-table/17264/5 "2022-12-27T19:14:59Z")

</div>

Yes! I can do that! But I just wondering why it print out different result from the video with exactly same code? I didn’t make any change of database?

---

<div class="post-metadata">

**Author:** ![SAM](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.codewithmosh.com/sam/32/167_2.png) [@SAM](https://forum.codewithmosh.com/u/SAM)\
**Post date:** [December 28, 2022, 6:08am UTC](https://forum.codewithmosh.com/t/join-multiple-table/17264/6 "2022-12-28T06:08:13Z")

</div>

You didn’t “write exactly the same code as video” otherwise at least the number of columns would have been the same as in the video.

The rows in the video screenshot you provided are also not ordered by order\_id.

If you don’t specifiy an explicit order you will get the results in an undefined order depending on the strategy the query optimizer chose to access the data. And that might depend e.g. on the exact query, the current number of rows in the tables involved,…
