Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9020985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:09:01+00:00 2026-06-16T05:09:01+00:00

So I have this problem that gives me headache. appreciate if anyone can help

  • 0

So I have this problem that gives me headache. appreciate if anyone can help me solve this.

I’m using Coldfusion with MSSQL together with MySQL. The MSSQL database is the main datasource for this application that i’m working on right now. While MySQL is used for the employee database (it was created to develop employee’s database with PHP). I have to connect to it in order to make this application work.

The MySQL tables:

TBL_EMPLOYEE

+---------+------------------+-------------------|
|EMP_ID   |    EMP_NUMBER    |    DATE_OF_BIRTH  |
+---------+------------------+-------------------|
| 1       |    00001         |    2009-01-01     |
| 2       |    00002         |    2009-01-15     |
| 3       |    TEMP01        |    2009-05-10     |  
| 4       |    TEMP02        |    2010-02-04     |
| 5       |    0006          |    2010-03-01     |
+---------+------------------+-------------------|

TBL_CHILD

+---------+------------------+---------------------|
|EMP_ID   |    CHILD_ID      |    DATE_OF_BIRTH    |

+---------+------------------+---------------------|
| 1       |    1             |    2008-11-12       |
| 1       |    2             |    2010-10-06       |
| 2       |    3             |    2009-05-10       |
| 5       |    4             |    2010-02-16       |
| 5       |    5             |    2012-03-08       |
+---------+------------------+---------------------|

This application will check a staff’s DOB. If he has kids, the system will display his eldest child’s DOB. Otherwise (if he doesn’t have kids) the system will display his own DOB.

Here is the problem:

<cfquery name="getEmployee" datasource="#mysqlDB#">
    SELECT EMP_ID,EMP_NUMBER,DATE_OF_BIRTH
    FROM   TBL_EMPLOYEE
    WHERE   EMP_NUMBER = '#users.EMP_NO[mainRow]#'
</cfquery>

<cfset mysql_id = getEmployee.EMP_ID>

<cfquery name="getChild" datasource="#mysqlDB#">
    SELECT *
    FROM   TBL_CHILD
    WHERE  EMP_ID =#mysql_id#
    ORDER BY DATE_OF_BIRTH ASC
    LIMIT 1
</cfquery>


Note : 
#users.EMP_NO[mainRow]# --> loop query from MSSQL
EMP_NUMBER = string
EMP_ID = integer (auto)

This query works when the employee number is numbers (i.e: 001, 101, 23002, etc)
(without the ” symbol )

<cfquery name="getEmployee" datasource="#mysqlDB#">
    SELECT *
    FROM    TBL_EMPLOYEE
    WHERE EMP_NUMBER = #users.EMP_NO[mainRow]#
</cfquery>

<cfset mysql_id = getEmployee.EMP_ID>

<cfquery name="getChild" datasource="#mysqlDB#">
    SELECT *
    FROM   TBL_CHILD
    WHERE  EMP_ID =#mysql_id#
</cfquery>

But it gives me error when employee number is character (TEMP101, TEMP007, etc).

 '#users.EMP_NO[mainRow]#'

I have tried to use the same query in phpmyadmin, it works just fine. Can anyone tell me why is this happening and how to solve this?

(Update from comments)
The error message is:

Error Executing Database Query. 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 ” at line 3 SELECT * FROM TBL_CHILD WHERE
EMP_ID =

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T05:09:03+00:00Added an answer on June 16, 2026 at 5:09 am

    Actually the error is caused by the difference of EMP_NUMBER in MSSQL and MySQL.

    eg:

    EMP NUMBER in MSSQL = 080, but in MySQL is stored as 80. 
    
    EMP NUMBER in MSSQL = 070, but in MySQL is stored as 70. 
    

    so to solve this, what i do is just to trim the mysql_id

    <cfset mysql_id =rereplace(mysql_id,'^0+','','ALL')>
    

    Thanks for all answers and am very sorry for the irrelevant question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this problem that I can ref a button for control it. I
I have a problem that I can't resolve. Let's say I have this map
I have a problem which I'm pretty sure that I can't solve without going
I have this problem that I cannot fix. From my @Controller , i can
I have this problem that my sites uses alot of ajax and when a
Ok I have this problem that I've never had before, it's really bugging me.
So we have this problem that we are trying to figure out. Heres what
I have this problem decomposing a relation schema into a set of schemas that
I have this annoying problem, that Im pretty sure happens to all of you
I have this little problem, that I cannot figure out which arguments to pass

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.