So what i'm trying to do is to SELECT all records from table1 that has a certain Project number. Then i will JOIN another table and get only one column named "FloorId" that is equal to both Project AND Element in table1.
(SELECT Project FROM dbo.IMP_MODEL_GEOMETRY WHERE dbo.IMP_GEOMETRY.Project = dbo.IMP_ELEMENT.Project AND dbo.IMP_GEOMETRY.Element = dbo.IMP_ELEMENT.Element)
In the dbo.IMP_GEOMETRY table i will get several results on Project and Element, so maby i can just select the first one.. DISTINCT?
This is what i have tried:
$sql = "SELECT * FROM dbo.IMP_ELEMENT WHERE Project LIKE '%$objNr%'
INNER JOIN dbo.IMP_MODEL_GEOMETRY ON dbo.IMP_ELEMENT.Project = dbo.IMP_MODEL_GEOMETRY.Project";
I am new to SQL and don't really know what the "." stands for in "dbo.IMP". The table name is: dbo.IMP_ELEMENT (I have seen querys where the dot marks the table and after the dot is the column name. But in this case the dot doesn't represent both table and column, it's just a dot in the table name.
Except in the JOIN where Project is the column (dbo.IMP_MODEL_GEOMETRY.Project)
The table i expect looks something like:
id Project Element FloorId
Where FloorId comes from table2.
EDIT
Both tables contains "Project" and "Element" So, i can use them to match. In table1 there is only one row per Project-Element but in table2 there can be multiple rows with Project-Element, so from table2 it's ok to only select the first match found.