Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder Bengal313's Avatar
    Join Date
    Jun 2002
    Location
    Metro Detroit
    Posts
    298
    Thanks
    8
    Thanked 0 Times in 0 Posts

    creating a dynamic sql statement

    I have two recordset in one page, "rslicense" and "rsaddressfromlicense".

    rsaddresfromlicense gets in query info from rslicense. I set up varibles that will take in the values from rslicense and use it in the query for rsaddressfromlicense. I just need to know how can I write a sql statement that will take the values in $NUMBER, $STREET, AND $APT, and use it to create the sql statement below.

    In Eglish: Select everything from table dog_header where HOUSE_NO is equal to the value in $NUMBER, STREET_NAME is equal to the value in $STREET and APT_NO is equal to the value in $APT;


    $NUMBER = $rslicense->Fields('HOUSE_NO')
    $STREET = $rslicense->Fields('STREET_NAME')
    $APT = $rslicense->Fields('APT_NO')

    $query_rsaddressfromlicense = sprintf("SELECT * FROM DOG_HEADER WHERE STREET_NAME = ??????????????????);
    "Knowledge Speaks But Wisdom Listens"

  • #2
    New Coder
    Join Date
    Jun 2002
    Posts
    73
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If i understand correctly you essentially just wrote it.


    $query_rsaddressfromlicense = sprint(select * from DOG_HEADER where HOUSE_NO=$NUMBER & STREET_NAME = $STREET & APT_NO = $APT);

    that is all you really need to do, if I understand you correctly. the $vars may need to be enclosed in single or double quotes, it really depends on the value you have the table columns set to.

  • #3
    Regular Coder Bengal313's Avatar
    Join Date
    Jun 2002
    Location
    Metro Detroit
    Posts
    298
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Exactly what I needed. Great! That Simple Huhh. Thanx
    "Knowledge Speaks But Wisdom Listens"


  •  

    Posting Permissions

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