New to MySL, please bear with me......
I have created two tables Clients and Jobs
One Client has many jobs.how do I create a relation between the two tables ?
I have searched the manual using terms like "relations" - "create
relations" etc etc to no avail.
Look up "join". The basic concept is that you match up common fields in the two tables in a query. For instance, since a job is always associated with a single client, there could be a ClientID column in both the Clients table and the Jobs table; in a join, you query MySQL telling it to match up the two on ClientID. An example of such a query would be:
SELECT * FROM Clients LEFT JOIN Jobs ON Clients.ClientID = Jobs.ClientID ;
The trick is the mindset you need: the relationship isn't stored in the database; it's defined during the query process. (I'm making this sound more absolute than it really is, but this is basically true.)
I won't explain it further now... if you have more questions after reading, ask away and we'll be glad to help!
Bruce Feist
--------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php