[thelist] SQL: ORDER with two parameters

Ken Schaefer ken at adOpenStatic.com
Wed Mar 31 04:13:50 CST 2004


D'oh

That's what Tab posted. If you have Access, then you need to put some
brackets in:

SELECT
     a.ID,
     a.ID_Type,
     a.Reference
FROM
     Doc_list AS a
INNER JOIN
(
        Doc_Relationships AS b
    INNER JOIN
        Doc_List AS C
    ON
        b.id_referer = c.ID
) ON
    a.ID = b.Id_doc
WHERE
     a.ID_Type = 2
ORDER BY
    c.reference,
    a.reference

----- Original Message ----- 
From: "Ken Schaefer" <ken at adOpenStatic.com>
To: <ad at netvisao.pt>; <thelist at lists.evolt.org>
Sent: Wednesday, March 31, 2004 7:44 PM
Subject: Re: [thelist] SQL: ORDER with two parameters


: You need to JOIN the view that you have back onto the Doc_List table (or
use
: a subquery - but this may not be supported by your DBMS). The following
: works for me:
:
: SELECT
:     a.ID,
:     a.ID_Type,
:     a.Reference
: FROM
:     Doc_list AS a
: INNER JOIN
:     Doc_Relationships AS b
: ON
:     a.ID = b.Id_doc
: INNER JOIN
:     Doc_List AS C
: ON
:     b.id_referer = c.ID
: WHERE
:     a.ID_Type = 2
: ORDER BY
:     c.reference,
:     a.reference
:
: HTH
:
: Cheers
: Ken
:
: Microsoft MVP - Windows Server (IIS)
:
: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
: From: "Adriano Castro" <ad at netvisao.pt>
: Subject: RE: [thelist] SQL: ORDER with two parameters
:
:
: :
: :     It's not working for me...
: :
: :     It says "Syntax error (missing operator) in query expression
: : 'd1.id=dr.id_doc INNER JOIN doc_list d2 ON dr.id_referrer=d2.id".
: :
: :     I the error's in the nested JOIN but can't seem to be able to clean
it
: : up.
: :
: :     Anyone?
: :
: :     Sorry about that but these are my 1st (real) steps in SQL.
: :
: :
: :     AD
: :
: :
: : Tab Alleman suggested:
: :
: : Maybe...
: :
: : SELECT d1.id, d1.id_type, d1.reference
: : FROM doc_list d1
: : INNER JOIN doc_relationships dr ON d1.id=dr.id_doc
: : INNER JOIN doc_list d2 ON dr.id_referrer=d2.id
: : WHERE d1.id_type=2
: : ORDER BY d2.reference, d1.reference
: :
: : ?
:
: -- 
: * * Please support the community that supports you.  * *
: http://evolt.org/help_support_evolt/
:
: For unsubscribe and other options, including the Tip Harvester
: and archives of thelist go to: http://lists.evolt.org
: Workers of the Web, evolt !
:



More information about the thelist mailing list