Field in ip_details are name, node, ip
Fields in name_details are name, node, used_mem,tot_mem
How to join two tables and fetch the node,name from name_details and ip from ip_details.
When I use join I get message as ambiguois
If you select name from both tables, the database cannot know which table you would like to use. So you need to use table.fieldname: select ip_details.name, ip_details.node, name_details.name from ...
You can avoid this by using unique fieldnames in your database. Furthermore, consider using ID colums in your database, a colum with auto_increment & key specified, to define which record links to other tables. Names are subject to duplication (Multiple people can have the same name) and misspellings, capitalisation issues etcetc.
But I get the error as name field is ambiguous
The table structure is
Ip_details -----------+-------------+------+-----+---------+-------+ | Field | Type | Null | Key | Default | Extra | +-----------+-------------+------+-----+---------+-------+ | name | varchar(50) | NO | PRI | | | | node | varchar(50) | NO | | | | | ip | varchar(16) | YES | | NULL | |
name_details; +------------------+---------------+------+-----+---------------------+-------+ | Field | Type | Null | Key | Default | Extra | +------------------+---------------+------+-----+---------------------+-------+ | name | varchar(50) | NO | PRI | | | node | varchar(50) | NO | | | | | timestamp | timestamp | NO | PRI | 0000-00-00 00:00:00 | | | | | status | decimal(3,2) | YES | | NULL | |
When i select name,node,ip from two tables I get message as name is ambiguious
Yes. That is why I told you to use table.fieldname. The fieldname 'name' is ambiguous when you use two table each of which has the field name.