MySQL , use values from one query to get a result from another -


i absolute newbie mysql , other basic select functions don't know more! have been reading various posts joining queries etc it's going on head far able build need , i'm short of time learn!

so able pull me query work out below, please?

i have 3 tables contain fields below need use.

accounts

i_account, id, i_env (this value =2), first_usage_time 

ua

i_ua, mac, inventory_id, description 

ua_links

i_ua, i_account 

so can see table ua_links contains 2 fields tie ua , accounts tables together.

what need is, output accounts table, id , first_usage along mac, inventory_id , description ua table.

hopefully makes sense?

many in advance mike

the simple way of doing create simple join.

select account.id, accounts.first_usage_time, ua.mac, ua.inventory_id, ua.description  accounts, ua, ua_links accounts.id = ua_links.i_account  , ua.i_ua = ua_links.i_ua 

a little explanation: can use comma select multiple tables. if want select column need use syntax {tablename}.{column_name}. connect 3 tables need link id's in statement.

i'm not totally sure if got correct columns, might want check (are ua.i_ua , ua_links.i_ua same?).


Comments