You are here: Re: Learning php Sql « PHP SQL « IT news, forums, messages
Re: Learning php Sql

Posted by Frankly on 07/17/06 21:30

"J.O. Aho" <user@example.net> wrote in message
news:4fqslqF1k82bvU1@individual.net...
> 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

the query worked fine after i removed the word table a few times and added
an S or 2 :).

SELECT *
FROM RelationManagementsBuildings
LEFT JOIN (
Managements, Buildings
) ON ( Managements.ManID = RelationManagementsBuildings.ManID
AND Buildings.BuildingID = RelationManagementsBuildings.BuildingID )
LIMIT 0 , 30


thank you.

Frank

 

Navigation:

[Reply to this 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

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