473,386 Members | 1,702 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1311
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
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...
6
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
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)...
0
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...
0
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...
0
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...
0
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...
0
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...
0
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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...

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.