Jump to content

Mysql Joins


peterg0123

Recommended Posts

Hi,

 

I am very new to mysql scripting and I am trying to write a query using joins.  The problem is that I only returns 1 row everytime where the categoryId = 29.  There are definetly other rows that should be returned?  Any help would be great...

 

SELECT
tbl_posts.id, tbl_posts.name, tbl_posts.description,tbl_posts.webUrl, tbl_posts.emailAddress,
tbl_posts.telNumber,tbl_posts.provinceId, tbl_posts.cityId,tbl_posts.creationDate,
tbl_posts.activated,tbl_post_categories.categoryId,tbl_provinces.name as provinceName,
tbl_cities.name as cityName, tbl_categories.name as categoryName

FROM tbl_posts

JOIN tbl_post_categories
	ON tbl_posts.Id = tbl_post_categories.postId
JOIN tbl_categories
	ON tbl_post_categories.categoryId = tbl_categories.id
JOIN tbl_provinces 
	ON tbl_posts.provinceId = tbl_provinces.id
JOIN tbl_cities 
	ON tbl_posts.cityId = tbl_cities.id

WHERE tbl_post_categories.categoryId ='29'

 

Thanks in advance,

Peter

Link to comment
https://forums.phpfreaks.com/topic/214418-mysql-joins/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.