SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Returning a binary char type from a mySQL query using ColdFusion

    This is a really odd occurrence and I wonder if anyone has run into themselves, or more importantly knows how to get around it.

    I'm using ColdFusion 6.1 with mySQL 4.0. Here's my data structure:
    eq_year - smallint(4)
    mfr_name - varchar(60)
    eq_model - varchar(12)

    and the query:
    SELECT CONCAT(' ', e.eq_year,' ', m.mfr_name,' ',e.eq_model) AS equipment
    FROM equipment e
    INNER JOIN manufacturer m
    ON m.mfr_id = e.fk_mfr_id

    The query itself runs just fine, but instead of returning a string for "equipment", it returns a binary number. So I recall this sort of thing happening before where the CAST function fixed it. So I try this query:
    SELECT CONCAT(' ', CAST(e.eq_year AS CHAR),' ', m.mfr_name,' ',e.eq_model) AS equipment
    FROM equipment e
    INNER JOIN manufacturer m
    ON m.mfr_id = e.fk_mfr_id

    And I get an error. Does anyone have any ideas about why this might be happening? Just to point out that it also throws an error when running the query straight in phpmyadmin. The easy solution would be to just convert the eq_year field to a char field, but that seems stupid.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  2. #2
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    and the error is...

  3. #3
    SitePoint Wizard creole's Avatar
    Join Date
    Oct 2000
    Location
    Nashvegas Baby!
    Posts
    7,845
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Don't worry about it. I didn't have time to try and figure it out so I just converted the column from smallint to a char (4) field. I'm not going to be doing any date calculations on this field, I just needed the year as a string basically.

    Thanks for asking though.
    Adobe Certified Coldfusion MX 7 Developer
    Adobe Certified Advanced Coldfusion MX Developer
    My Blog (new) | My Family | My Freelance | My Recipes

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by creole
    Just to point out that it also throws an error when running the query straight in phpmyadmin. The easy solution would be to just convert the eq_year field to a char field, but that seems stupid.
    well, since you've already gone and converted the smallint to char(4), let's discuss the error the next time you encounter it

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

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