CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2005
    Posts
    141

    mysql order by column from another table

    hi

    i'd try to ask in the most simple manner...

    i've a table named 'first' which contains these field:

    user | name | points

    and second table named 'second' which contain these field

    user | title |



    my question is, I want to select all fields in table 'second' and sort them based on the value of column 'points' from table1.. how do I do it?

    btw i'm trying to use PHP to do this... but I asked in the database forum since I think it's mostly a mysql issue..

    thanks in advance

  2. #2
    Join Date
    Jun 2006
    Posts
    437

    Re: mysql order by column from another table

    Hi all.

    Yes, it's a database topic.
    If table first is linked to table second with user field, as I image, you can write something like this

    Code:
    SELECT S.*
      FROM FIRST F, SECOND S
     WHERE F.USER = S.USER
     ORDER BY F.POINTS
    I hope this will help you.

  3. #3
    Join Date
    Jul 2005
    Posts
    141

    Re: mysql order by column from another table

    ooouh...thanks a lot davide... that's exactly what I needed!

    thanks again

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured