SQL Query

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Aaron

    #1

    SQL Query

    My db table looks like this
    FILENAME FILE_CREATED FILE_MODIFIED
    test 9/12
    test2 9/13 10/13
    ..
    ..
    all FILE_CREATED field have value, only some FILE_MODIFIED have value.

    I need to get the value of FILENAME column and this is what i have

    SELECT FILENAME FROM REW_FILES WHERE FILE_CREATED =@cDate AND
    FILE_MODIFIED = @mDate

    This problem with this query is that it would return null if the
    FILE_MODIFIED field is empty.

    How can I write a query that ignores " AND FILE_MODIFIED = @mDate" if
    FILE_MODIFIED is null?

    Thanks
  • Miha Markic

    #2
    Re: SQL Query

    Hi Aaron,

    If I understand properly:
    SELECT FILENAME FROM REW_FILES WHERE FILE_CREATED =@cDate AND (FILE_MODIFIED
    = @mDate OR FILE_MODIFIED IS NULL)

    --
    Miha Markic - RightHand .NET consulting & development
    miha at rthand com
    100% satisfaction guaranteed on every domain we sell. 30-day, no questions asked, money-back guarantee. Easy, fast and convenient shopping.



    "Aaron" <kuya789@yahoo. com> wrote in message
    news:b4828959.0 312301436.73418 d9d@posting.goo gle.com...[color=blue]
    > My db table looks like this
    > FILENAME FILE_CREATED FILE_MODIFIED
    > test 9/12
    > test2 9/13 10/13
    > .
    > .
    > all FILE_CREATED field have value, only some FILE_MODIFIED have value.
    >
    > I need to get the value of FILENAME column and this is what i have
    >
    > SELECT FILENAME FROM REW_FILES WHERE FILE_CREATED =@cDate AND
    > FILE_MODIFIED = @mDate
    >
    > This problem with this query is that it would return null if the
    > FILE_MODIFIED field is empty.
    >
    > How can I write a query that ignores " AND FILE_MODIFIED = @mDate" if
    > FILE_MODIFIED is null?
    >
    > Thanks[/color]


    Comment

    • William Ryan

      #3
      Re: SQL Query

      SELECT FILENAME FROM REW_FILES WHERE (FILE_CREATED =@cDate AND
      FILE_MODIFIED = @mDate) OR File_Created=@c Date
      "Aaron" <kuya789@yahoo. com> wrote in message
      news:b4828959.0 312301436.73418 d9d@posting.goo gle.com...[color=blue]
      > My db table looks like this
      > FILENAME FILE_CREATED FILE_MODIFIED
      > test 9/12
      > test2 9/13 10/13
      > .
      > .
      > all FILE_CREATED field have value, only some FILE_MODIFIED have value.
      >
      > I need to get the value of FILENAME column and this is what i have
      >
      > SELECT FILENAME FROM REW_FILES WHERE FILE_CREATED =@cDate AND
      > FILE_MODIFIED = @mDate
      >
      > This problem with this query is that it would return null if the
      > FILE_MODIFIED field is empty.
      >
      > How can I write a query that ignores " AND FILE_MODIFIED = @mDate" if
      > FILE_MODIFIED is null?
      >
      > Thanks[/color]


      Comment

      • Dan Brussee

        #4
        Re: SQL Query

        On 30 Dec 2003 14:36:03 -0800, kuya789@yahoo.c om (Aaron) wrote:
        [color=blue]
        >My db table looks like this
        >FILENAME FILE_CREATED FILE_MODIFIED
        >test 9/12
        >test2 9/13 10/13
        >.
        >.
        >all FILE_CREATED field have value, only some FILE_MODIFIED have value.
        >
        >I need to get the value of FILENAME column and this is what i have
        >
        >SELECT FILENAME FROM REW_FILES WHERE FILE_CREATED =@cDate AND
        >FILE_MODIFIE D = @mDate
        >
        >This problem with this query is that it would return null if the
        >FILE_MODIFIE D field is empty.
        >
        >How can I write a query that ignores " AND FILE_MODIFIED = @mDate" if
        >FILE_MODIFIE D is null?[/color]

        You might want to rethink what you are asking for. Why would you ask
        for a file that was created on date X and modified on date Y, but want
        to see one that was never modified? How would you know a date to
        search for in the Modified column if it was not modified? Im thinking
        maybe what you are looking for is some code that will handle a case
        where the value you are passing in for the Modified column is "null".
        Is this the case?



        Comment

        Working...