MySQL Forums
Forum List  »  Newbie

Re: Select an array from one databank and compare it to one from another databank
Posted by: Barry Galbraith
Date: November 26, 2015 03:09PM

>Now I guess, I have to users numbers for that and replace them on the next page via a connection to mysql

Yep. You can populate a dropdown SELECT box by querying your 'subjects' table.
Use the subject_id as the value for the option, and the subject_name for the display text for the option.
When the form data is posted, the subject_id is placed in the appropriate field in the 'requests' table.

Adding subjects becomes a matter of adding then to the subjects table, with no rewrite of the webpage.

A JOIN gives all matching rows from the two tables.
A LEFT JOIN gives all rows from the first (left) table and matching rows from the second table.
A subtlety of a LEFT JOIN is that if you use WHERE to filter for rows where the right table is NULL, you'll get rows that are in the LEFT table, but not the RIGHT. It's called an EXCLUSION JOIN, because you are excluding rows that do match.

There are other types of JOIN, but you will mostly use JOIN, and LEFT JOIN.

The order of the joins is only important in a LEFT JOIN.
There is also a RIGHT JOIN, which is similar to a LEFT JOIN, except you get all the rows from the second table, and only matching rows form the the left. From a maintenance point of view, it's easier to manage LEFT JOIN.

>And the order of the join:
As long as the two tables/fields listed in the ON clause have been JOINed, then it doesn't matter the order of the JOIN, except for LEFT JOIN, see above.

Good luck,
Barry.

Options: ReplyQuote




Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.