Re: Display Records in certain order (string contained in field)



Randy wrote:
Just can't figure out how to do this..........
I have a simple asp page that desplays images from database.

What database? Type and version please ... these are almost always relevant
and they are definitely relevant for this question.

The query on my page:
-------------------------
imagequery = "SELECT * FROM FILE_LIST WHERE CLASS_ID=" & FORM_ID

Nothing to do with your problem but ...
http://www.aspfaq.com/show.asp?id=2096

------------------------
The table FILE_LIST contains a field called TITLE which never gets
displayed.
(the form_id comes from a selection on previous page)
I display the images with a do loop as follows:
---------------------------
I hope I've explained this adequately.
Thanks in advance to anyone who has any ideas.

I cannot get specific, but the sql dialect for whatever database you are
using undoubtedly has string functions to enable you to accomplish this in
your sql statement. Like this:

Access:
imagequery = "SELECT * FROM FILE_LIST " & _
"WHERE CLASS_ID=" & FORM_ID & _
" ORDER BY iif(Instr([TITLE],"photo")>0,0,1) ASC

SQL Server:
imagequery = "SELECT * FROM FILE_LIST " & _
"WHERE CLASS_ID=" & FORM_ID & _
" ORDER BY CASE WHEN TITLE Like '%photo%' " & _
"THEN 0 ELSE 1 END ASC"


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


.



Relevant Pages

  • Re: SQL Update: How do I get more error information
    ... // Write it back to the database - if it was changed ... , (SQL ... This email account is my spam trap so I ...
    (microsoft.public.data.ado)
  • Re: Problem w/ VBScript running against SQL Server 2000
    ... bay_id is the identity field in your database. ... account for sql injection anyway. ... This email account is my spam trap so I ...
    (microsoft.public.scripting.vbscript)
  • Re: Unicode Website/Forms save to SQL-Server2000 Problem
    ... .cz-chars like this: 'Ohrvace'. ... Field-Type in database is nvarchar. ... Create a limited-rights sql login to use in your application. ... This email account is my spam trap so I ...
    (microsoft.public.inetserver.asp.db)
  • Re: Error updating SQL Server with Recordset
    ... I'm moving from Access to SQL Server and I'm getting the following ... should make the cursor non-updatable regardless of the database. ... Personally, I prefer using stored procedures, or saved parameter queries as ... This email account is my spam trap so I ...
    (microsoft.public.inetserver.asp.db)
  • Re: syntax error connecting database
    ... access database, but i keep getting the following error: ... sql string you have built via concatenation in vbscript. ... You cannot troubleshoot a sql statement without knowing what it is. ... This email account is my spam trap so I ...
    (microsoft.public.inetserver.asp.db)

Loading