Jump to content

Query Help


therealwesfoster

Recommended Posts

Ok, there are 3 tables.

 

1. Categories

2. Posts (goes under the categories)

3. Relation (links the posts to the category).

 

I need help constructing a query that will select the post_id from the "posts" table WHERE post_title="THIS_TITLE" AND post_category (the category ID must come from the relation table) ="THIS_CATID".

 

Usually (if the category id was insite the posts table) I would do something like this:

SELECT post_id FROM posts WHERE post_title="TITLE" AND post_category="CATID"

.

 

But since there isn't a column in the posts table named "post_category", I need the query to check in the "Relation" table in order to get it.

 

This is for wordpress if that makes any difference (you can see how their DB structure is)

 

Wes

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.