Join 2 queries

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • semko
    New Member
    • Jul 2007
    • 1

    #1

    Join 2 queries

    I have two select statments:

    FIRST:
    [CODE=mysql]select org.org_dij_org anization_id org_id, org.kasa kasa
    from org_dijelovi_ka se org;[/CODE]

    SECOND:
    [CODE=mysql]select 'PROIZVODI' from dual
    union
    select 'BARKODOVI' from dual
    union
    select 'STAVKE_CJENOVN IKA' from dual;[/CODE]

    Both two selects give me results, which i want in one table. How to select parameters i want and put them in one table!?

    THANK YOU !!!
    Last edited by mwasif; Jul 27 '07, 11:05 AM. Reason: Added code tags.
  • mwasif
    Recognized Expert Contributor
    • Jul 2006
    • 802

    #2
    PROIZVODI, BARKODOVI, STAVKE_CJENOVNI KA
    These are column names or you want to return these as it is?

    Your first query returns 2 columns and 2nd query returns single column.
    You can combine these 2 queries with UNION and to compensate the 2nd column you have to use NULL e.g.

    [CODE=mysql]SELECT org.org_dij_org anization_id org_id, org.kasa kasa
    FROM org_dijelovi_ka se org
    UNION
    SELECT 'PROIZVODI', NULL FROM dual
    UNION
    SELECT 'BARKODOVI', NULL FROM dual
    UNION
    SELECT 'STAVKE_CJENOVN IKA', NULL FROM dual;[/CODE]
    Make sure the data type must be same for the first column.

    Is this is not what you are looking for, then please provide some sample data.

    Comment

    Working...