I have a table called Articles. I also have a table for Tags. The tags table actually has 2 separate tables as its a many-to-many relationship between Articles and Tags. For example:
CREATE TABLE Articles (
id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT
title VARCHAR(255),
author INT UNSIGNED NOT NULL,
body TEXT NOT NULL -- column type may not be representative
) Engine=InnoDB;
CREATE TABLE Tags (
id INT UNSIGNED PRIMARY KEY AUTO_INCREMENT,
name VARCHAR(32)
) Engine=InnoDB;
CREATE TABLE Article_Tags (
article INT UNSIGNED NOT NULL,
tag INT UNSIGNED NOT NULL,
FOREIGN KEY (article) REFERENCES Articles (id),
FOREIGN KEY (tag) REFERENCES Tags (id)
) Engine=InnoDB;
Now, is it possible to do a single query to return an article, and also all the tags related to that article from the Tags table in the same query?
select * from table1 inner join table2 on table2.table1ID = table1.id inner join table3 ON table3.id = table2.table3idwheretable2is your link table.CREATE TABLEstatements) is more useful than any ad-hoc table schema or english description of table columns.