One of your goals should be to have as few queries as possible.  If you 
want to do it as one query you might do something like:

<cfquery...>
select tblJobTitle.Title, 1 as SortCol
from tblJobTitle
where tblJobTitle.Table_ID = 25
UNION
select tblJobTitle.Title, 2 as SortCol
from tblJobTitle
where tblJobTitle.Table_ID = 26
UNION
select tblJobTitle.Title, 3 as SortCol
from tblJobTitle
where tblJobTitle.Table_ID = 28
UNION
select tblJobTitle.Title, 4 as SortCol
from tblJobTitle
where tblJobTitle.Table_ID = 4

order by 2
</cfquery>

Here's a rough explanation:
Since you're specifying the table ID, you can't have it in your order 
by.  Each query in the UNION select is grabbing the data as if it's a 
single query.  The difference is that you have all 4 results in one 
recordset.  This makes things easier to work with as far as the output.

Notice that the order by refers to a number, not a name... when doing a 
UNION select you have to order by the column number (hence the SortCol 
field we're creating).

Hope this helps!
Hatton

Paul Ihrig wrote:

> Man!
> you guys went way over my head hear!
> : ]
> 
> for this purpose
> since there are only 4 separate groupings
> i may just do 4 separate queries.
> 
> not sure.
> 
> thought i could do it like
> Order By tblJobTitle.TitleID=25, tblJobTitle.TitleID=26,
> tblJobTitle.TitleID=28, tblJobTitle.TitleID=4;
> 
> 
> -paul
> 
______________________________________________________________________
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to