I have 2 tables on MySQL: phy and VM.
Here is the phy table:
and here is the VM table:
I want to get a result like an image below:
I type the command below like this:
select ip, name, brand, vm.mem, vm.mem FROM phy JOIN vm ON phy.ip = vm.ip
but the result is like this:
what command do I have to type in order for me to get the result I want?
2
Answers
The query assumes that
ip
is defined as primary/unique key in both tables.The query won’t return the data for
ip
if it is present in one of these tables only. If you need such data then you’d useOr, if the presence is optional in one table only, use (for optional presence in
vm
, for example)