SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist Miguel61's Avatar
    Join Date
    Mar 2008
    Posts
    402
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Problem with output query sql

    Hello everyone.

    I try this query in the Db MySQL and not receive error:

    PHP Code:
    SELECT 
    A
    .ESERCIZIOA.EVENTOA.DATA
    A.ORAA.ORIGINEA.`DURATA GLOBALE`, 
    A.`DESCRIZIONE NODO`, A.LINEAA.`DESCRIZIONE LINEA`, 
    CA.NUMEROCA.SommaDiNclientiBTNULLNULL 
    FROM tbl_A A
    tbl_CA CA 
    WHERE A
    .LINEA=CA.idLINEA 
    AND A.DATA='2008-11-12' 
    AND A.ESERCIZIO='DM20' 
    UNION 
    SELECT A.ESERCIZIONULLA.DATA
    NULLNULLNULLNULL
    A.LINEANULLNULLB.cl_BTB.cl_MTNULL 
    FROM tbl_A A
    tbl_B B 
    WHERE B
    .Cod_linea=A.LINEA 
    AND A.DATA='2008-11-12' 
    AND A.ESERCIZIO='DM20' 
    ORDER BY ORA DESC 
    But in the output I dont see the value of B.cl_MT... why?

    MR

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,216
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    because the result set produced by a UNION query uses column names that are taken from the first SELECT

    thus, values of B.cl_MT are located in the 12th column, but you have failed to name this column
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist Miguel61's Avatar
    Join Date
    Mar 2008
    Posts
    402
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Thanks r937 I understand my error !


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
  •