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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.