Hello All,
I am working on a small PHP / Mysql project and I have ran aground on this issue, and I am looking for some advice as to why this is not working. What I am trying to acheive is to show a list of blog post titles, along with their respective categories that they are assigned too, However I am unable to get my query to work. below are my 3 tables structure:
The Posts table
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| postname | varchar(255) | NO | | NULL | |
| postcontent | varchar(255) | NO | | NULL | |
| postdate | date | NO | | NULL | |
| authorid | int(11) | NO | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
The Category Table
+-------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+--------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| name | varchar(255) | NO | | NULL | |
+-------+--------------+------+-----+---------+----------------+
The Lookup table
+------------+---------+------+-----+---------+-------+
| Field | Type | Null | Key | Default | Extra |
+------------+---------+------+-----+---------+-------+
| postid | int(11) | NO | PRI | 0 | |
| categoryid | int(11) | NO | PRI | 0 | |
+------------+---------+------+-----+---------+-------+
My query
mysql> select id, postname from posts join postcategory on posts.id = categoryid;
Empty set (0.00 sec)
so far example it should look like this on the web page
Post Name Post Category
Linux DNS How Too Linux
Windows 10 Hacks Windoiws
Again grateful for any help.
Joe