SQL error with 2 statements

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default SQL error with 2 statements

    Hi
    Can anyone tell me whats wrong with this SQL statement below?
    The first bit is supposed to only show records less than 1 year old (which
    works fine on it's own) and the next a standard query for a search form
    (also works fine on it's own).
    I'm trying to put both statements together on one page but I keep getting
    errors when I test the statement.

    SELECT *
    FROM upload
    WHERE Date>DateAdd('yyyy',-1,Now()); WHERE area = 'varName' AND pax LIKE
    'varName2' AND rooms LIKE 'varName3


    woodywyatt Guest

  2. Similar Questions and Discussions

    1. If Statements????
      guys i was wondering if anybody here could help me. I have a page done up with all dynamic text and attributes on it that come from a management...
    2. Syntax error in INSERT INTO and UPDATE statements
      maybe this is a noob question and i've been stairing at my screen too long trying to find the error but I'm having problems using the Insert into...
    3. 2 sql statements in one <cfquery>
      hi. is it possible to do something like this? <cfquery datasource="chDev" name="test"> SELECT * FROM test WHERE id = #url.id# INSERT INTO test...
    4. If statements in PHP?
      How do i get something to show only if the user is logged in? For example, "log out" should only show if the user is logged in and "log in" should...
    5. If/else statements - help.
      Sorry to post so much code all at once but I'm banging my head against the wall trying to get this to work! Does anyone have any idea where I'm...
  3. #2

    Default Re: SQL error with 2 statements

    You've got WHERE in there twice

    --
    Jules
    [url]http://www.charon.co.uk/charoncart[/url]
    Charon Cart 3
    Shopping Cart Extension for Dreamweaver MX/MX 2004




    Julian Roberts Guest

  4. #3

    Default Re: SQL error with 2 statements

    Hi Jules
    Excuse my ignorance but do I just leave it out? Something like -

    SELECT *
    FROM upload
    WHERE Date>DateAdd('yyyy',-1,Now()); area = 'varName' AND pax LIKE
    'varName2' AND rooms LIKE 'varName3

    Thanks
    Gary

    "Julian Roberts" <newsg@charon.co.uk> wrote in message
    news:d3b18d$fpj$1@forums.macromedia.com...
    > You've got WHERE in there twice
    >
    > --
    > Jules
    > [url]http://www.charon.co.uk/charoncart[/url]
    > Charon Cart 3
    > Shopping Cart Extension for Dreamweaver MX/MX 2004
    >
    >
    >
    >

    woodywyatt Guest

  5. #4

    Default Re: SQL error with 2 statements

    You'd already got most of the logic sussed, you'd use AND. ie

    SELECT *
    FROM upload
    WHERE Date>DateAdd('yyyy',-1,Now()) AND area = 'varName' AND pax LIKE
    'varName2' AND rooms LIKE 'varName3


    --
    Jules
    [url]http://www.charon.co.uk/charoncart[/url]
    Charon Cart 3
    Shopping Cart Extension for Dreamweaver MX/MX 2004




    Julian Roberts Guest

  6. #5

    Default Re: SQL error with 2 statements

    Thanks for your hepl Julian
    I found it worked the other way round with variable first -

    SELECT *
    FROM upload
    WHERE area = 'varName' AND pax LIKE 'varName2' AND rooms LIKE 'varName3'AND
    Date>DateAdd('yyyy',-1,Now())

    Cheers
    Gary


    "Julian Roberts" <newsg@charon.co.uk> wrote in message
    news:d3b3l2$if0$1@forums.macromedia.com...
    > You'd already got most of the logic sussed, you'd use AND. ie
    >
    > SELECT *
    > FROM upload
    > WHERE Date>DateAdd('yyyy',-1,Now()) AND area = 'varName' AND pax LIKE
    > 'varName2' AND rooms LIKE 'varName3
    >
    >
    > --
    > Jules
    > [url]http://www.charon.co.uk/charoncart[/url]
    > Charon Cart 3
    > Shopping Cart Extension for Dreamweaver MX/MX 2004
    >
    >
    >
    >

    woodywyatt Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139