473,890 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DataGrids and MySQL join?

I have a situation where I have 2 tables - NODES and TAGS. Nodes is the
main table and contains various columns one of which is tagID. Tags
contains a list of tag names and tagIDs. When a user adds an entry to
the Nodes table they can specify one or more tags for the entry. Then
when the form is posted if there were multiple tags in the post their
tagIDs are comma seperated before being inserted in the tagID column of
the Nodes table.
This all works fine and dandy.

The issue is that I then want to be able to display a list of Nodes
with their details including which tags are associated with them.
To display most of the Node info is easy and I am currently binding a
DataReader to a DataGrid to do this. However I need now to show the
tags for each Node so need to do some type of join in MySQL (I assume)
to get the tag names from their tagIDs. But this is further complicated
by the fact that each node may have comma seperated, mulitple tagIDs
associated with it and I need to put those into an array (or similar)
first in order to be able to treat them as integers before being able
to do much with them.
I'm sure I could write some custom code, ditching the datagrid, in
order to do this but am wondering whether there is a better way to do
it using other .NET objects - or whether the answer lies with SQL.

Any ideas?

Aug 4 '06 #1
2 1344
Are your tables one to one realted or one to many, i.e. does each nodes
record have one tags record containing multiple comma seperated values or
does each tag have it's own record.

If it is the latter then you can put the two tables in a DataSet create a
relation and then use the GetChildRows method for each row in the Nodes
record set and it will return an array of DataRows for the realted tags.

"JP2006" wrote:
I have a situation where I have 2 tables - NODES and TAGS. Nodes is the
main table and contains various columns one of which is tagID. Tags
contains a list of tag names and tagIDs. When a user adds an entry to
the Nodes table they can specify one or more tags for the entry. Then
when the form is posted if there were multiple tags in the post their
tagIDs are comma seperated before being inserted in the tagID column of
the Nodes table.
This all works fine and dandy.

The issue is that I then want to be able to display a list of Nodes
with their details including which tags are associated with them.
To display most of the Node info is easy and I am currently binding a
DataReader to a DataGrid to do this. However I need now to show the
tags for each Node so need to do some type of join in MySQL (I assume)
to get the tag names from their tagIDs. But this is further complicated
by the fact that each node may have comma seperated, mulitple tagIDs
associated with it and I need to put those into an array (or similar)
first in order to be able to treat them as integers before being able
to do much with them.
I'm sure I could write some custom code, ditching the datagrid, in
order to do this but am wondering whether there is a better way to do
it using other .NET objects - or whether the answer lies with SQL.

Any ideas?

Aug 4 '06 #2
The first; each node record has one tagID record potentially containing
many comma seperated tagIDs.
I have since written some code, without a DataGrid, using 2 arrays to
capture the node table data and the tags table data and then compare
the 2 on the tagID column. It works although it is a bit lengthy!

clickon wrote:
Are your tables one to one realted or one to many, i.e. does each nodes
record have one tags record containing multiple comma seperated values or
does each tag have it's own record.

If it is the latter then you can put the two tables in a DataSet create a
relation and then use the GetChildRows method for each row in the Nodes
record set and it will return an array of DataRows for the realted tags.

"JP2006" wrote:
I have a situation where I have 2 tables - NODES and TAGS. Nodes is the
main table and contains various columns one of which is tagID. Tags
contains a list of tag names and tagIDs. When a user adds an entry to
the Nodes table they can specify one or more tags for the entry. Then
when the form is posted if there were multiple tags in the post their
tagIDs are comma seperated before being inserted in the tagID column of
the Nodes table.
This all works fine and dandy.

The issue is that I then want to be able to display a list of Nodes
with their details including which tags are associated with them.
To display most of the Node info is easy and I am currently binding a
DataReader to a DataGrid to do this. However I need now to show the
tags for each Node so need to do some type of join in MySQL (I assume)
to get the tag names from their tagIDs. But this is further complicated
by the fact that each node may have comma seperated, mulitple tagIDs
associated with it and I need to put those into an array (or similar)
first in order to be able to treat them as integers before being able
to do much with them.
I'm sure I could write some custom code, ditching the datagrid, in
order to do this but am wondering whether there is a better way to do
it using other .NET objects - or whether the answer lies with SQL.

Any ideas?
Aug 4 '06 #3

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

Similar topics

13
5570
by: aaron | last post by:
I have a question about (i think) joining. If I have a table in a database that has this info: key - name - favorite 1 - john - 2 2 - judy - 3 3 - joe - 1 the favorite icecream table is this:
6
3085
by: Xenophobe | last post by:
I know this isn't a MySQL forum, but my question is related to a PHP project. I have two tables. table1 table2 "table1" contains 2 columns, ID and FirstName:
23
2578
by: phpfrizzle | last post by:
Hi there, I have a site with products on it. The site has a mysql backend. All products belong to certain series (table series). There can be up to 4 different products (table products) (categories 1-4) in 1 series. Each product has a defined 'series ID' which tells us
0
3546
by: Lenz Grimmer | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi, MySQL 4.0.14, a new version of the popular Open Source/Free Software Database, has been released. It is now available in source and binary form for a number of platforms from our download pages at http://www.mysql.com/downloads/ and mirror sites.
0
2370
by: Soefara | last post by:
Dear Sirs, I am experiencing strange results when trying to optimize a LEFT JOIN on 3 tables using MySQL. Given 3 tables A, B, C such as the following: create table A ( uniqueId int not null default 0 auto_increment, a1 varchar(64) not null default '',
0
1391
by: Phil Powell | last post by:
I have a rather complicated query with a combination of LEFT JOINs and two MATCHES where the first match is non-boolean to get the accurate score, the second to search as boolean: SELECT image.id, image.image_name, (MATCH (image_name, image_alt, image_location_city, image_location_state, image_location_country) AGAINST ('test')
0
3959
by: Mike Chirico | last post by:
Interesting Things to Know about MySQL Mike Chirico (mchirico@users.sourceforge.net) Copyright (GPU Free Documentation License) 2004 Last Updated: Mon Jun 7 10:37:28 EDT 2004 The latest version of this document can be found at: http://prdownloads.sourceforge.net/souptonuts/README_mysql.txt?download
0
2301
by: yeahuh | last post by:
Quick and dirty version. Godaddy server using MySQL 4.0.24 I’m trying a left join to obtain id’s in table A(cars) that are NOT in car_id in table B(newspaper): *This is a cut down version to simplify testing. Full version is posted towards the end. SELECT C.id FROM cars C LEFT OUTER JOIN newspaper N USING (C.id=N.car_id) WHERE N.car_id IS NOT NULL;
0
2173
by: jllanten | last post by:
I will appreciate any help you can provide me. In the company where i work we have a project which creates about 4-5M records daily of stats. We're currently storing this data in a db named 'summary' which contains all the stats data for up to 15 days. After that we begin to move the data in a daily basis to a single 'archived like' unique table in another fast performance mysql instance. Why we do this ? to respect the 80%-20% rule: 80% of...
0
9976
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
9815
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11215
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
10451
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
9618
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...
1
8008
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7160
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5835
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...
1
4665
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.