Announcement

Collapse
No announcement yet.

select with field

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • select with field

    i use this select:
    /**
    * Selecting a field from another table
    */



    // Check for record
    $check_sql = "SELECT
    termine_pagamento
    FROM
    clienti
    WHERE
    (id = '{id}')";
    sc_lookup(rs, $check_sql);

    if (isset({rs[0][0]})) // Row found
    {
    {modalita_pagamento} = {rs[0][0]};

    }
    else // No row found
    {
    {modalita_pagamento} = '';

    }

    my primary key is id, but want change with another field is possible? example:
    new field test is not primay key:
    /**
    * Selecting a field from another table
    */



    // Check for record
    $check_sql = "SELECT
    termine_pagamento
    FROM
    clienti
    WHERE
    (test = '{id}')";
    sc_lookup(rs, $check_sql);

    if (isset({rs[0][0]})) // Row found
    {
    {modalita_pagamento} = {rs[0][0]};

    }
    else // No row found
    {
    {modalita_pagamento} = '';

    }

  • #2
    In general you can use any sql statement you like/need. No matter how complex. I would leave out the () btw.
    Albert Drent
    aducom software netherlands
    scriptcase partner, reseller, support and (turn-key) development
    www.scriptcase.eu / www.scriptcase.nl

    Comment

    Working...
    X