+ Reply to Thread
Results 1 to 2 of 2

Thread: Order database columns

  1. #1
    Junior Member
    Join Date
    Jan 2012

    Order database columns

    I have two tables : Count table and Links table with 3 columns : id, linkname, linkurl
    I want to order the 'linkname' column in order of the count column and put it in an array. I am struggling becasue i am not understanding how to use JOIN.
    I need to get linkid WHERE userid = $userid

  2. #2
    Junior Member
    Join Date
    Jan 2012
    Try this:
    $userid = intval( $userid ); // Hopefully it's already an integer, 
                                 // but protect yourself from SQL Injection
    SELECT linkname, C.count FROM Links INNER JOIN `Count` C ON C.linkid = Links.id
    WHERE userid = $userid
    ORDER BY C.count ASC

+ Reply to Thread

Tags for this Thread


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts