-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Sunday 20 July 2003 14:18, Veysel Harun Sahin wrote:
> Hello,
>
> I have to join two columns from different tables in a query. Assume that
> I have two tables:
>
> staff
> id    company_Id       name
> 1        1                    FirstName
> 2        1                    SecondName
> 3        2                    ThirdName
>
> company
> company_Id          owner
> 1                        MyOwnerName
> 2                        SecondOwnerName
>
> Here I need to join the columns staff.name and company.owner from two
> tables with the name joined_column so I can do order by on them. For
> example when I query two tables with the company_id = 1 I want to get a
> resultset like this:
>
> joined_column
> --------------------
> FirstName
> MyOwnerName
> SecondName
>
> Any comments?

This is a UNION query. For example:

        Select name as Joined_column from Staff where company_id = 1
                UNION
        Select owner as Joined_column from company where company_id = 1;

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2-rc1-SuSE (GNU/Linux)

iD8DBQE/Gv6YjeziQOokQnARAmoLAKCf6NSmFaLG5foQYZtbHpeGuUZJOgCgrINR
Q1SFb1eu7DUXAIV/44savs8=
=4h+/
-----END PGP SIGNATURE-----


-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to