Internal question
CREATE TABLE college
(
id SERIAL PRIMARY KEY,
SCHOOL VARCHAR(100),
CColor VARCHAR(100),
CCmascot VARCHAR(100)
);
CREATE TABLE mats
(
id SERIAL PRIMARY KEY,
CColor VARCHAR(100),
CCNAME VARCHAR(100)
);
MYSQL So here's the problem, I think it's pretty simple, but I don't get it. I have the name SCHOOL passed to me via a url and I use $ _GET to get the college name I need to query:
Using the name SCHOOL I need to get the CCOLOR and CCNAME.
source to share
You have the name of the college and you want to know the name of the color if I understand correctly.
The linking attribute is CColor.
Your request should look something like this:
select
m.ccname, m.ccolor
from
mats m
inner join
college c
on
c.ccolor = m.ccolor
where
c.school = @myVariable
source to share
Your question is not clear, so the answer can only be approximate. You need columns in both tables that can be used to join them, i.e. columns that have values ββthat can be used to identify when record / s in parent table (college) matches record / s in child table (mats). ideally you should have a foreign key on the maps of the child tables that could be named college_id (this uses a naming convention that refers to the parent table).
Providing a foreign key like the above would
select
college.ccolor
from
college inner join mats
on college.id = mats.college_id
where
mats.ccname = "<<COLOUR_DESIRED>>";
Assuming ccname is ccolor.
source to share
Database tip of the day: Use foreign key constraints , or you will have data corruption issues and the people at SO won't know how your columns relate to each other.
Once you know the whys and whatfors of relational modeling, you may find it necessary to do without them (although this is not recommended unless you have a really good reason), but for now, use them to explicitly define how tables relate to each other.
Otherwise, your question is kind of like asking the chef, "I have some unlabeled cans of food and I think it's oregano. How can I make a romantic dinner for two?" (Umm .. what's in the jars?)
Foreign foreign key: http://dev.mysql.com/doc/refman/5.1/en/ansi-diff-foreign-keys.html
Attach documentation: http://dev.mysql.com/doc/refman/5.1/en/join.html
source to share