0

i'm still learning...i have two database tables

setting: id, uid, deptid
user :  id, uid, name

i want the result to be sort ascending by name from user table

$result = $DB->query("SELECT s.*, u.* FROM ".$myDB->prefix("setting")." AS s LEFT JOIN ".$myDB->prefix("user")." AS u ON s.uid=u.uid ORDER BY u.name ASC");  

please advice..Thank you

sabahan
  • 41
  • 1
  • 8

1 Answers1

0
SELECT setting.*, user.* FROM setting LEFT JOIN user ON setting.uid = user.uid ORDER BY user.name ASC 

Also, look in to which join you'll want to be using to get the right data. The venn diagrams on these pages easily represent what data will be shown.

In my experience, it's usually the Inner join I look at working with.

Bejasc
  • 930
  • 1
  • 8
  • 20