473,387 Members | 1,420 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,387 software developers and data experts.

connect 2 different columns from 2 tables

i need to connect 2 different columns from 2 tables.

note the these columns are strings (varchar)

column on 1st table: description1
column on 2nd table: description2

example:
description1: corporate unit staff
description2: corporate unit staff/division head/finance

i did some string manipulation.
variable.ToString.Substring(0, (DataTable.Rows(0)("description2")).ToString.Index Of("/"))

how do i connect these tables using inner join in sql or code behind?
Aug 24 '07 #1
9 2225
dip_developer
648 Expert 512MB
i need to connect 2 different columns from 2 tables.

note the these columns are strings (varchar)

column on 1st table: description1
column on 2nd table: description2

example:
description1: corporate unit staff
description2: corporate unit staff/division head/finance

i did some string manipulation.
variable.ToString.Substring(0, (DataTable.Rows(0)("description2")).ToString.Index Of("/"))

how do i connect these tables using inner join in sql or code behind?
Dont you want to join these two tables on any primary key??
if not then simply use the UNION operator....like

SELECT description1 FROM table1
UNION
SELECT description2 FROM table2

Note: This command cannot be used to list all descrition in table1 and table2. If there is description with the same name then only one will be listed. The UNION command only selects distinct values.

If you want all values then use UNION ALL operator like.....

SELECT description1 FROM table1
UNION ALL
SELECT description2 FROM table2

is this the answer you want??? let us know.
Aug 24 '07 #2
Dont you want to join these two tables on any primary key??
if not then simply use the UNION operator....like

SELECT description1 FROM table1
UNION
SELECT description2 FROM table2

Note: This command cannot be used to list all descrition in table1 and table2. If there is description with the same name then only one will be listed. The UNION command only selects distinct values.

If you want all values then use UNION ALL operator like.....

SELECT description1 FROM table1
UNION ALL
SELECT description2 FROM table2

is this the answer you want??? let us know.
not exactly the answer im looking for.

my main concern is AFTER the string manipulation. i couldnt join the two tables because they give different values like ive mentioned earlier. so i need to do string manipulation first for Description2 to connect them
Aug 24 '07 #3
Shashi Sadasivan
1,435 Expert 1GB
not exactly the answer im looking for.

my main concern is AFTER the string manipulation. i couldnt join the two tables because they give different values like ive mentioned earlier. so i need to do string manipulation first for Description2 to connect them
On what basis do you want to connect the 2 tables?
Aug 24 '07 #4
dip_developer
648 Expert 512MB
not exactly the answer im looking for.

my main concern is AFTER the string manipulation. i couldnt join the two tables because they give different values like ive mentioned earlier. so i need to do string manipulation first for Description2 to connect them
what type of string manipulation you want......be more specific.......give some example if possible....
Aug 24 '07 #5
what type of string manipulation you want......be more specific.......give some example if possible....
1st table has column1 that contains a value, Corporate
2nd table has column2 that contains a value, Corporate/staff/unit

Expand|Select|Wrap|Line Numbers
  1. pac2 = pac.ToString.Substring(0, pac.ToString.IndexOf("/"))
  2.  
after the manipulation of the string in column2, it results to "Corporate" which is the basis for the connection of the two tables.

how do i connect these two tables using sql or code behind. also, i have 3 more tables to connect with. so the use of inner join is, i think, imperative.
Aug 24 '07 #6
On what basis do you want to connect the 2 tables?
the string. the other table doesnt have a primary. so i have to base on the string (varchar) instead. which the columns of these 2 tables are different. i only need the string before the slash ("/") to connect these
Aug 24 '07 #7
Shashi Sadasivan
1,435 Expert 1GB
the string. the other table doesnt have a primary. so i have to base on the string (varchar) instead. which the columns of these 2 tables are different. i only need the string before the slash ("/") to connect these
Still not sure what you are looking for!
any examples?
from what i can figure out, you want to output 2 columns, and show the columns from the second table whose field starts with the string of field of the first table.

Expand|Select|Wrap|Line Numbers
  1. select t1.c1, t2.c1 from table1 t1, table2 t2
  2. where t1.c1 like concat('%',t1.c1,'%')
Aug 24 '07 #8
Still not sure what you are looking for!
any examples?
from what i can figure out, you want to output 2 columns, and show the columns from the second table whose field starts with the string of field of the first table.

Expand|Select|Wrap|Line Numbers
  1. select t1.c1, t2.c1 from table1 t1, table2 t2
  2. where t1.c1 like concat('%',t1.c1,'%')
i tried the code u gave me. there was an error.

i want to connet these 2 tables based on a string data type.

column1 in table1 = corporate
column2 in table2 = corporate/staff/unit

i did a string manipulation in column2. so it becomes "corporate". this is for the connection of table1 to table2. the problem is, how do i join them with the other 3 tables. will i use inner join or just code it in code behind?
Aug 24 '07 #9
dip_developer
648 Expert 512MB
i tried the code u gave me. there was an error.

i want to connet these 2 tables based on a string data type.

column1 in table1 = corporate
column2 in table2 = corporate/staff/unit

i did a string manipulation in column2. so it becomes "corporate". this is for the connection of table1 to table2. the problem is, how do i join them with the other 3 tables. will i use inner join or just code it in code behind?
still very confusing...why dont you use three different fields for corporate,staff and unit in the second table....???
Aug 24 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Wonderinguy | last post by:
Our websphere application uses a generic application userid to connect and query db2 on z/os via DB2 connect. The end user,logs in to the application using his regular userid, which is then...
17
by: Wilfried | last post by:
Hi, I have 5 tables: main data1
7
by: Luis Esteban Valencia | last post by:
I have this i need to show the datagrid with columns of 2 datatables Dim myadap As New SqlDataAdapter myconn.Open() myadap.TableMappings().Add("Table", "vistaUsuarios")
2
by: sal | last post by:
Greets, all I'm trying to create different multiple mailing type labels on a page reading from an untyped dataset anyone have any ideas on how I can get this done without crystal reports a plan...
9
by: serge | last post by:
/* Subject: How to build a procedure that returns different numbers of columns as a result based on a parameter. You can copy/paste this whole post in SQL Query Analyzer or Management Studio...
5
by: explode | last post by:
I made a procedure Public Sub Novo(ByVal nova1 As String, ByVal nova2 As String) that creates a new oledbDataAdapter with insert update select and delete commads. I also added that commands can...
2
by: Jim | last post by:
Hello everyone, This is my first time posting to a Usenet group, so please excuse any Netiquette errors I may have in my post. I have used ASP.NET before using C#, but never VB, so I'm trying...
3
by: cberthu | last post by:
Hi all, Is it possible to have two connects in the same rexx script to different DB's? I have to get data form on DB (with specifics selects and filter out some values with RExx) and save the...
6
by: Al G | last post by:
Can someone tell me what I need to get connected to our AS400? I am trying to write an app in VS2005(Data source, Gridview) that requires data from files on our AS400. I've downloaded DB2, and...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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.