Link to home
Start Free TrialLog in
Avatar of koila
koilaFlag for Australia

asked on

Select a field from a table in coldfusion.

I have a online form and I'm displaying the email field from the email table.  This field is not valid anymore.  So here is the current script.  Please see attached images.

<CFQUERY NAME="DisplayEmail" datasource="aar" username="#application.username#" password="#application.password#">
    SELECT *
    FROM email
    WHERE email.user_id = #client.user_id#
    </CFQUERY>

   <tr>
              <td height="21">E-Mail:</td>
              <td height="21"><cfoutput>
              #DisplayEmail.email#
                  <input type="hidden" name="email" value="#DisplayEmail.email#">
                </cfoutput>      

Now I want do a change and I would like to display the 'official_email' from the ENR table.
I've tried and it didn't work.

FYI, the enrollee_id_number is primary key into the ENR table which is identical to the foreign key id_number in users table.

How can I do it.. .

  SELECT official_email
    FROM enr, users
    where enr.enrollee_id_number = select .....
ENR.jpg
users.jpg
emailtable.jpg
ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of koila

ASKER

I will test it    Thanks
Avatar of koila

ASKER

FYI.  Is not the same id.  
WHERE enrollee_id_number  = #client.user_id#
Avatar of koila

ASKER

Good morning gdemaria,

Please see attached scripts results into my comments.  So this is an example for this username .

I need to retrieve this field 'official_email' from my database enrollees... Maybe you have to do select into select.. not sure.  .

Into your code below the Enrolle id_number is 972432 will be not equal to the client.use_id which is 16885

<CFQUERY NAME="DisplayEmail" datasource="aar" username="#application.username#" password="#application.password#">
    SELECT official_email
      FROM enr
    WHERE enrollee_id_number  = #client.user_id#

</CFQUERY>

Please advise. thanks!
EmailTableResults.jpg
EnrolleesTableResults.jpg
UsersTableResults.jpg
Avatar of koila

ASKER

Would you please help me on this questions.
Avatar of koila

ASKER

Could you please review this question below.
Avatar of koila

ASKER

Please note that you have respond to my question in general but to not my specific question querry.  I will post this in a separate question, if you are intested please change the script according to the requirements.

thanks.