Results 1 to 15 of 15

Thread: an if clause in a sql query

Threaded View

  1. #1

    Thread Starter
    Frenzied Member wengang's Avatar
    Join Date
    Mar 2000
    Location
    Beijing, China
    Posts
    1,604

    Resolved an if clause in a sql query

    hi all.
    I'm just wondering if I can reduce the recordset size on my web page.

    I have a query like:
    select Top 50 ID, Field1,field2,field3 from tblRecords where....

    Field1 in this example is very large text field, and since there are 50, the page is slow.

    In fact, I don't need the text field to be returned, what I need is a true or false value to indicate if a substring is present in the field. And I do need the other fields. So I can't restrict this in the where clause.

    What I need is:
    Select Top 50 ID, Field2, Field3, (if field1 like '%MyPhrase%' Then True Else False) where....

    So the top 50 records are returned, but instead of the big text field of data, a True or False is returned per record.

    Is that possible? Cast the field type somehow?

    Anybody know this? Thanks.

    Wengang
    Last edited by wengang; Jun 28th, 2005 at 08:04 PM.
    Wen Gang, Programmer
    VB6, QB, HTML, ASP, VBScript, Visual C++, Java

Posting Permissions

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



Click Here to Expand Forum to Full Width