|
Posted by J.O. Aho on 06/20/06 18:21
Frankly wrote:
>>> CREATE DATABASE `myweb325573_grace`;
>> This creates the database itself, you don't need this at this moment, as
>> it's already created.
>>
>>
>>> DROP TABLE IF EXISTS `myweb325573_grace`.`RelationManagementsBuildings`;
>> This removes the table RelationManagementsBuildings, if it already exists
>> in the database.
>>
>
> those are just statements that were included when i copied the SQL.
>
>>> CREATE TABLE `RelationManagementsBuildings` (
>>>
>>> `ManID` int(10) unsigned NOT NULL default '0',
>>>
>>> `BuildingID` int(10) unsigned NOT NULL default '0',
>>>
>>> PRIMARY KEY (`ManID`,`BuildingID`),
>> This seems okey.
>>
>>> CONSTRAINT `FK_RelationManagementsBuildings_1` FOREIGN KEY (`ManID`)
>>> REFERENCES `Managements` (`ManID`) ON DELETE CASCADE ON UPDATE CASCADE
>> Haven't used Constraints and cascades, I guess I should read on them, but
>> the part here you could drop without it affecting the main functionality
>> of the table, if you remove this, don't forget to remove the comma after
>> the definition of the primary keys.
>
> but isnt this the part the creates the actual join? this is where I am
> having trouble. i did that one fine
> but when i try to make the join using the 2nd part of the primary key which
> is Buildings and make the join with the buildings table is when i get the
> mysql error 1005 (errno:150) if i dont need this join than my tables are
> complete. lol at least i think they are.
http://dev.mysql.com/doc/refman/5.0/en/join.html
SELECT * FROM RelationManagementsBuildings LEFT JOIN (ManagementsTable,
BuildingTable) ON (ManagementTable.ManID=RelationManagementsBuildings.ManID
AND BuildingTable.BuildingID=RelationManagementsBuildings.BuildingID)
I think the join looks like this, now you would get all the data from both
ManagementsTable and BuildingTable as if they where all stored in the same table.
//Aho
[Back to original message]
|