SELECT dependant on parameters

  • I think i posted this in the wrong place, so i'll put it here 

    Hi,

    Is there a way (through case or if statements i assume) to select rows from a table depending on a parameters value?

    i.e.

    @customerID int

    if customerID = (certainValue)

    select * from Table where customerID = @customerID

    else

    select * from table

    Thanks for your time

    Lee

  • SELECT *

    FROM table

    WHERE ( @customerID = (CertainValue) AND customerID = @customerID)

    OR @customerID (CertainValue)

    That should do ya...

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply