SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    how to use CONCAT inside a SELECT

    Code MySQL:
    SELECT t_request_detail.REQ_CO, t_request_detail.EU_NAME, m_model.MODEL_NA, t_request_detail.QTY_DEF, CONCAT(t_request_detail.SVC_Y, " years, ", t_request_detail.SVC_M, " months")
    FROM t_request_detail 
     LEFT JOIN m_model ON t_request_detail.MODEL_CO = m_model.MODEL_CO
    )

    Can anyone explain why the use of CONCAT above causes an error?

  2. #2
    SitePoint Zealot falsealarm's Avatar
    Join Date
    Sep 2008
    Posts
    147
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not seeing the data I'm going to guess it's a LEFT JOIN issue as there seems to be no syntax error with your SQL statement. Do you have to use a LEFT JOIN or can you try an natural join?

  3. #3
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,495
    Mentioned
    161 Post(s)
    Tagged
    4 Thread(s)
    What's the error?

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,220
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    there is no error, although single quotes to delimit strings would be better, since that would be standard sql

    i'm guessing this sql statement is inside doubleqoutes in a php assignment

    $sql = "SELECT....

    that would produce an error
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  5. #5
    SitePoint Enthusiast
    Join Date
    Aug 2006
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i was misled by the sql error, after simplifying the query i found that one of the col names was wrong.


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
  •