SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Evangelist Scheisskopf's Avatar
    Join Date
    Nov 2004
    Location
    Southampton, UK
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    sort in multiple tables

    I have the following sql:
    PHP Code:
    "( select message_board.`date`, admin.* from message_board inner join admin on message_board.id = admin.id where
    message_board.name = 'dave' ) union ( select time_spent.`date`, admin.* from time_spent inner join
    admin on time_spent.id = admin.id where time_spent.name = 'dave' ) " 
    i would like to sort my results by id, job_title and client_name (latter two are in admin) - how would i add this to my sql code?

    Thanks.

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    695
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    select message_board.`date`, admin.* 
    from message_board inner join admin on message_board.id = admin.id 
    where message_board.name = 'dave' 
    union 
    select time_spent.`date`, admin.* 
    from time_spent inner join admin on time_spent.id = admin.id 
    where time_spent.name = 'dave' 
    order by admin.id, admin.job_title , admin.client_name

  3. #3
    SitePoint Evangelist Scheisskopf's Avatar
    Join Date
    Nov 2004
    Location
    Southampton, UK
    Posts
    537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    doesn't work - says unknown table admin in order clause

  4. #4
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    695
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Of course, you shouldn't need any table prefix

    Code:
    select message_board.`date`, admin.* 
    from message_board inner join admin on message_board.id = admin.id 
    where message_board.name = 'dave' 
    union 
    select time_spent.`date`, admin.* 
    from time_spent inner join admin on time_spent.id = admin.id 
    where time_spent.name = 'dave' 
    order by id, job_title , client_name


Bookmarks

Posting Permissions

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