Results 1 to 2 of 2
  1. #1
    Join Date
    May 2003
    Posts
    2

    Unanswered: Help with creating a view

    Greetings,

    I'm trying to convert following query to a view


    $query = 'SELECT
    f.id,
    f.top_pos,
    f.left_pos,
    f.height,
    f.width,
    f.type,
    CASE WHEN f.required = \'t\' THEN \'true\' ELSE \'false\' END as required,
    f.class_id_fk,
    f.visible,
    i.value,
    i.field_id_fk,
    i.pdf_user_id_fk
    FROM
    pdf_field f
    LEFT JOIN
    pdf_input i
    ON
    (i.field_id_fk = f.id AND i.pdf_user_id_fk = ?)
    WHERE
    f.pdf_id_fk = ?
    AND
    f.page_num = ?
    AND
    f.visible = \'t\'';


    My current view looks like this


    CREATE OR REPLACE VIEW fields_view AS
    SELECT
    f.id,
    f.top_pos,
    f.left_pos,
    f.height,
    f.width,
    f.type,
    CASE WHEN f.required = 't' THEN 'true' ELSE 'false' END as required,
    f.class_id_fk,
    f.pdf_id_fk,
    f.page_num,
    f.visible,
    i.value,
    i.field_id_fk,
    i.pdf_user_id_fk
    FROM
    pdf_field f
    LEFT JOIN
    pdf_input i
    ON
    (i.field_id_fk = f.id)

    and I'm not having any luck with the following

    (i.field_id_fk = f.id AND i.pdf_user_id_fk = ?)

    How do I pass this parameter to a view????


    Thanks
    ~kat

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    Reference the view name like a table from a query, and add a WHERE condition to the query.

    Code:
    Select * from fields_view Where pdf_user_id_fk = 7
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


Posting Permissions

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