Skip to content

Instantly share code, notes, and snippets.

@AlphaWong
Created July 27, 2017 08:11
Show Gist options
  • Save AlphaWong/32ed6ca27a8d6ee82305ea83e75f68c3 to your computer and use it in GitHub Desktop.
Save AlphaWong/32ed6ca27a8d6ee82305ea83e75f68c3 to your computer and use it in GitHub Desktop.
join.sql
SELECT * FROM vanorderspecialrequest as a right join th_vanlookupspecialrequests as b on a.idvanspecialrequest = b.id where b.enable = 1;
SELECT * FROM vanorderspecialrequest as a left join th_vanlookupspecialrequests as b on a.idvanspecialrequest = b.id where b.enable = 1;
# A table (Master) vs B table (non-master)
# A table (1,2,3,4,5)
# b table ({orderId:1,user:'alpha'},{order:2,user:'beta'})
# if A join B will not deduct the total result
# if B join A will deduct total result
# SQL performance groups by two section
# 1. sql caculation and
# 2. total response result.
# Importance need to clear the mysql cache
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment