MySQL Forums
Forum List  »  Newbie

Join tables query
Posted by: angelo rigo
Date: July 06, 2005 11:23AM

Hi
I need to select news from a news table with the same sport code related in a news_sports table:

news table:
id_news
title

news_sports table:
id_news
id_sport

the querys would be:
//Select many sports id in news_sports with id_news being the only researched new
$sql_rel1 = "SELECT id_sport FROM news_sport WHERE id_news = $bd_id_news"

//Select many news ids in news_sport wich id_sport = sports id researched by the last query
$sql_rel2 = "SELECT id_news FROM news_sport WHERE id_sport = $bd_id_sports"

//Select mews id in news table with the resulting ids from the last query
$sql_rel3 = "SELECT id_news, title FROM news WHERE id_news = $bd_id_news"

This can be done with only one query? how can it be done?

Or:

Do i have to use many querys and do a foreach or something like this?

ThankĀ“s in advance

Options: ReplyQuote


Subject
Written By
Posted
Join tables query
July 06, 2005 11:23AM
July 06, 2005 12:40PM
July 06, 2005 01:17PM
July 06, 2005 01:28PM
July 06, 2005 01:50PM
July 06, 2005 02:00PM
July 06, 2005 02:08PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.