Results 1 to 3 of 3

Thread: and clause in query

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Jun 2007
    Location
    Karachi
    Posts
    551

    and clause in query

    hi to every one

    can I put insert and in case clause of sql server ?? like




    case 'M' and tx>0 then 'Good'
    There is no achievement without goals

  2. #2
    Frenzied Member
    Join Date
    May 2014
    Location
    Central Europe
    Posts
    1,372

    Re: and clause in query

    i am not sure what you mean with 'insert'. Insert statement?
    if you just ask for a combination of conditions within a case when construct then this should do what you ask for:

    case when (field=M and tx>0) then 'Good' else 'Bad' end

    note that this is different from

    case field when 'M' then 'Good' else 'Bad' end

    the latter one is similar to a select case in vb where you have one value and match it with different possibilities while the first one is more like a if (..) elseif (..) construct where you can check for different things in each if

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,537

    Re: and clause in query

    The short answer is no... if you need compound cases like that, it all needs to be moved down into the when clause as digitalshaman has shown.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

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