sql - How do I write this MySQL query? -


I am working on Asset DB using a lamp stack.

The following 5 tables in this example:

Property, server, laptop, desktop, software

All tables have a primary key of ID, Property ID is.

Everything is all property attributes and then there are additional properties in the respective table based on the type of property. If there is a type server, desktop or laptop then there are items in the software table.

Here are the tables:

  // connect to mysql server and database "asset_db" mysql_connect ("localhost", "asset_db", "asset_db") or die (Mysql_error ()); Mysql_select_db ("asset_db") or die (mysql_error ()); // Property table mysql_query ("Make TABIL property (id VARCHAR (50) primary key, company VARCHAR (50), location VARCHAR (50), purchase_date VARCHAR (50), purchase_start VARCHAR (50), value VARCHAR (50) type VARCHAR (50), notes "Varchar (200)" or "Mysql_query" (create mysql_error ()); echo created property table.   ID VARCHAR (50) Primary key, software VARCHAR (50), license VARCHAR (50)) "or die (mysql_error ()); echo" software table created. & Lt; / br / & gt; "; (50) ACC VARCHAR (50), User Varchar (50), model VARARAR (50), model VARCHAR (50), model VARCHAR (50), table table of mysql_query ("Create Table Laptop (ID VARCHAR (50) Primary Key, Manufacturer VARCHAR (50) Prev_user VARCHAR 50), warranty VARCHAR (50) "or die (mysql_error ()); echo" created the laptop table.   

How do I query the database so that if I search with ID,

Thank you.

/ Div>

  select asset .id, asset.company, asset.location -, ... any other column from the property, soft Software, software, software, software, laptop.model AS laptop_model, desktop.model AS DesktopModel - etc., Collages (laptop.model, server.model, desktop model) AS model - only a non-tap software.id = Leave the software on software.id = asset.id to add the desktop on the laptop id.exe.asset.id on asset.id Add desktop on the desktop.id = asset.id server except server.id = asset.id WHERE asset.id = & Lt; your_id & gt;  

Comments