Sheriff Said Elahl Sheriff Said Elahl - 2 years ago 126
MySQL Question

MYSQL Nested Query with two select

I have:

Table1 (UserID -City - Adress - Mobile)
Table2 (DeviceID - UserID - Vendor - Model).

I want to perform nested query to select the following in one row:

select DeviceID, UserID, Model From Table2 Where Vendor=Sony
(and for this row go and select City - Address - Mobile from table 1 where table1.UserID = Table2.UserID)

How can I perfom the second select in the same query to be printed in the same row after Model.

Answer Source

Use inner JOIN

    , t2.UserID
    , t2.Model
    , t1.Address
From Table2 as t2
Where Vendor='Sony'
INNER JOIN table1 as t1 on  t1.UserID = t2.UserID
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download