Creating a view

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

    Creating a view

    I am having a terrible time trying to create a view. Here is the sql
    string:

    $sql = "CREATE VIEW v AS SELECT * FROM t1;";

    Here is the error:

    You have an error in your SQL syntax; check the manual that corresponds
    to your MySQL server version for the right syntax to use near 'VIEW v
    AS SELECT FROM t1' at line 1

    So simple, yet so vexing. Any thoughts? Thanks,

    -- whit nelson

  • Jerry Stuckle

    #2
    Re: Creating a view

    Whit wrote:
    I am having a terrible time trying to create a view. Here is the sql
    string:
    >
    $sql = "CREATE VIEW v AS SELECT * FROM t1;";
    >
    Here is the error:
    >
    You have an error in your SQL syntax; check the manual that corresponds
    to your MySQL server version for the right syntax to use near 'VIEW v
    AS SELECT FROM t1' at line 1
    >
    So simple, yet so vexing. Any thoughts? Thanks,
    >
    -- whit nelson
    >
    This isn't a PHP question. Try a mysql newsgroup - such as
    comp.databases. mysql.

    And ensure your version of MySQL supports views.

    --
    =============== ===
    Remove the "x" from my email address
    Jerry Stuckle
    JDS Computer Training Corp.
    jstucklex@attgl obal.net
    =============== ===

    Comment

    • Wolfgang

      #3
      Re: Creating a view

      Hello.

      Perhaps it's only the the ";" within the command at the end ?
      ....SELECT * FROM t1;"; <- the one in front of the "

      The error in syntax message doesn't have this one.

      Hope helps,
      Wolfgang


      "Whit" <whitnelson@gma il.comschrieb im Newsbeitrag
      news:1157238723 .312572.36260@i 3g2000cwc.googl egroups.com...
      I am having a terrible time trying to create a view. Here is the sql
      string:
      >
      $sql = "CREATE VIEW v AS SELECT * FROM t1;";
      >
      Here is the error:
      >
      You have an error in your SQL syntax; check the manual that corresponds
      to your MySQL server version for the right syntax to use near 'VIEW v
      AS SELECT FROM t1' at line 1
      >
      So simple, yet so vexing. Any thoughts? Thanks,
      >
      -- whit nelson
      >

      Comment

      • IchBin

        #4
        Re: Creating a view

        Whit wrote:
        I am having a terrible time trying to create a view. Here is the sql
        string:
        >
        $sql = "CREATE VIEW v AS SELECT * FROM t1;";
        >
        Here is the error:
        >
        You have an error in your SQL syntax; check the manual that corresponds
        to your MySQL server version for the right syntax to use near 'VIEW v
        AS SELECT FROM t1' at line 1
        >
        So simple, yet so vexing. Any thoughts? Thanks,
        >
        -- whit nelson
        >
        Looks fine to me. So make sure the version of MySQL you have supports
        view. It started to be supported in MySQL version 5.0. The ';' in the
        SQL statement is fine. It is a cmd terminator in SQL.

        IMHO - If you want to use a view I would use it on complicated SQL table
        relationships. I see no reason to build a view based on just one SQL table.

        --
        Thanks in Advance...
        IchBin, Pocono Lake, Pa, USA http://weconsultants.phpnet.us
        'If there is one, Knowledge is the "Fountain of Youth"'
        -William E. Taylor, Regular Guy (1952-)

        Comment

        • frothpoker

          #5
          Re: Creating a view

          I would concur.

          My hosted service doesn't support views. I had to write a 5 nested
          level select statement to do what I wanted. Seeing as you have to
          write the complicated SQL to generate a view anyway, why not just stick
          it in a function and call it with the required parameters. How big is
          the database and what is the likely overhead.

          Obiron

          Comment

          Working...