[thelist] SQL: ORDER with two parameters
Ken Schaefer
ken at adOpenStatic.com
Wed Mar 31 03:44:18 CST 2004
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
:
: ?
More information about the thelist
mailing list