Reply to Re: Learning php Sql

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация