473,651 Members | 2,496 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Select items with same catehory as given item

Hey

I have two tables:

TABLE_ARTICLE
article_id***** *article_name article_content

TABLE_ARTICLE_S ECTION
article_id *section_id
Given an article_id, how do I select all articles from
TABLE_ARTICLE that have the same section_id as that of a given
article_id.

Something like this but for mysql:
SELECT table_article.* FROM table_article,t able_section WHERE
table_section.s ection_id IN (SELECT section_id FROM table_section
WHERE article_id="som ething")

Thanks
Joshua
Jul 19 '05 #1
2 1597
BDR
select * from TABLE_ARTICLE
LEFT JOIN TABLE_ARTICLE_S ECTION ON
(TABLE_ARTICLE. article_id=TABL E_ARTICLE_SECTI ON.article_id)
WHERE TABLE_ARTICLE.a rticle_id='some thing'

Check mysql.com for other variants on this same theme... "table JOIN(s)"
http://www.mysql.com/doc/en/JOIN.html

Jadow wrote:
Hey

I have two tables:

TABLE_ARTICLE
article_id article_name article_content

TABLE_ARTICLE_S ECTION
article_id section_id
Given an article_id, how do I select all articles from
TABLE_ARTICLE that have the same section_id as that of a given
article_id.

Something like this but for mysql:
SELECT table_article.* FROM table_article,t able_section WHERE
table_section.s ection_id IN (SELECT section_id FROM table_section
WHERE article_id="som ething")

Thanks
Joshua


Jul 19 '05 #2
BDR
select * from TABLE_ARTICLE
LEFT JOIN TABLE_ARTICLE_S ECTION ON
(TABLE_ARTICLE. article_id=TABL E_ARTICLE_SECTI ON.article_id)
WHERE TABLE_ARTICLE.a rticle_id='some thing'

Check mysql.com for other variants on this same theme... "table JOIN(s)"
http://www.mysql.com/doc/en/JOIN.html

Jadow wrote:
Hey

I have two tables:

TABLE_ARTICLE
article_id article_name article_content

TABLE_ARTICLE_S ECTION
article_id section_id
Given an article_id, how do I select all articles from
TABLE_ARTICLE that have the same section_id as that of a given
article_id.

Something like this but for mysql:
SELECT table_article.* FROM table_article,t able_section WHERE
table_section.s ection_id IN (SELECT section_id FROM table_section
WHERE article_id="som ething")

Thanks
Joshua


Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
13062
by: Charlotte Henkle | last post by:
Hello; I'm pondering how to count the number of times an item appears in total in a nested list. For example: myList=,,] I'd like to know that a appeared three times, and b appeared twice, and the rest appeard only once.
0
460
by: Jadow | last post by:
Hey I have two tables: TABLE_ARTICLE article_id      article_name article_content TABLE_ARTICLE_SECTION article_id  section_id
4
11258
by: headware | last post by:
I have a <select> control that contains many entries. It allows the user to multi-select a group of them, click a button, and store the selected data in a database. Normally they do this starting at the top of the list moving down towards the bottom. The problem I was having was that the <select> control was scrolling back to the top of the page after the postback and the user would lose their place in the <select> control forcing them to...
6
4287
by: Ben Hallert | last post by:
Hi guys, I'm trying to figure out what bone headed mistake I made on something I put together. I've got a form (named 'context') that has a variable number of select-multiple inputs on it. Based on the number of variables passed through a GET string, I want to multiply the total number of selected items for each together to see how many possible combinations the selected items are generating. The following snippet of code...
13
2804
by: andro | last post by:
Hi everybody! I have several tables from which I want to exract the SAME value (along with other referenced data). All the values are in the same column within the tables. How can I achieve this? TIA. Andro
5
10075
by: Phill W. | last post by:
(VB'2003) What's the correct way to remove multiple, selected items from a ListView control (say, from a ContextMenu)? I ask because I'm getting a very annoying ArgumentOutOfRangeException because the ListView seems to be trying to "re-select" items that are no longer there! for example, giventhat I have 3 items in my list: Select the first and remove it - no problem.
3
6424
by: Beholder | last post by:
I hope that someone can help me with the following: Short background explenation: I have a shrfepoint page (newform.aspx) in a item list. On this page is a lookup column that displays a lookup of all category items in previous items. In the code this results in a select/options list like this: <SELECT TABINDEX=1 NAME="urn:schemas-microsoft-com:office:office#CatLookup"><OPTION
1
4020
by: Sunray | last post by:
I have a form called the sales form and i have 2 sets of listboxes So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which are not bound, I select from the bottom set and add to the top set which works fine, but now i decide to remove an item from the top set. when i tried to use a remove item code it worked fine, it did delete the item form the list but it added...
2
2813
by: phpnewbie26 | last post by:
I currently have two drop down menus where the second one is populated from the first one. My second drop down menu should be able to do multiple selection. I have searched online and found out how to do so (add in multiple and put brackets after name), but unfortunately when I retrieve the data on the next page, it seems that none of the selections were added to the variable array. On the other hand, it "POST"-ed the null value which is 1. My...
0
8352
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8802
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8697
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8579
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7297
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4144
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4283
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1587
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.