473,387 Members | 3,810 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.

Comma delimited

Hello there,

I am new in using SQL 2000. Please help me to find out how to create a select query or function to return the expected result below.

Table 1: User_Table

UserID | xName | xCode
---------------------------------------------
1 | XYZ | SG3,SG9
2 | ABC | KR12,KR13

Table 2: Outlet_Table

Outlet_ID | xCode
-------------------------------------------------------
987654 | KR12
77777 | SG9


Create a query that will display the expected result below:

Outlet_ID | xCode | UserID
----------------------------------------------------------------
987654 | KR12 | 2
77777 | SG9 | 1


Please help.

Kindest regard,
jen
Dec 6 '07 #1
6 1761
amitpatel66
2,367 Expert 2GB
Hello there,

I am new in using SQL 2000. I need to find out how to create a select query or function from the below.

Table 1: User_Table

UserID xName xCode
------------------------------------------------
1 XYZ SG3,SG9
2 ABC KR12,KR13

Table 2: Outlet_Table

Outlet_ID xCode
---------------------------------
987654 KR12
77777 SG9


Create a query that will display the expected result below:

Outlet_ID xCode UserID
----------------------------------------------------------------
987654 KR12 2
77777 SG9 1

Please help.

Kindest regard,
jen
Try this query:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT ot.outlet_id,ot.xcode,ut.user_id FROM
  3. outlet_table ot, user_table ut
  4. WHERE ut.xcode LIKE '%ot.xcode%'
  5.  
  6.  
Dec 6 '07 #2
Try this query:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT ot.outlet_id,ot.xcode,ut.user_id FROM
  3. outlet_table ot, user_table ut
  4. WHERE ut.xcode LIKE '%ot.xcode%'
  5.  
  6.  

Thank you for a very quick reply.
Using Line 3. WHERE ut.xcode LIKE '%ot.xcode%' did not return any result.
I tried to add a bracket WHERE ut.xcode LIKE '%[ot.xcode]%' but the result ID is not correct. :(
Dec 6 '07 #3
Hello there,

I am new in using SQL 2000. Please help me to find out how to create a select query or function to return the expected result below.

Table 1: User_Table

UserID | xName | xCode
---------------------------------------------
1 | XYZ | SG3,SG9
2 | ABC | KR12,KR13

Table 2: Outlet_Table

Outlet_ID | xCode
-------------------------------------------------------
987654 | KR12
77777 | SG9


Create a query that will display the expected result below:

Outlet_ID | xCode | UserID----------------------------------------------------------------
987654 | KR12 | 2
77777 | SG9 | 1


Please help.

Kindest regard,
jen

Hello,

Please help me solve this comma delimited case.. the table i am querying has no primary key or even common field except for the Outlet_Table.xCode and Outlet_ID.xCode.

Regards,

Jen
Dec 11 '07 #4
amitpatel66
2,367 Expert 2GB
Hello,

Please help me solve this comma delimited case.. the table i am querying has no primary key or even common field except for the Outlet_Table.xCode and Outlet_ID.xCode.

Regards,

Jen
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SQL> SELECT outlet_table.oid, user_table.id, outlet_table.xc,user_table.xc FROM
  3.   2  (select 1 AS id, 'XYZ' AS xname, 'SG3,SG9' AS xc FROM DUAL) user_table,
  4.   3  (SELECT 999999 AS oid, 'SG9' AS xc FROM DUAL) outlet_table
  5.   4  WHERE INSTR(user_table.xc,outlet_table.xc) > 0
  6.   5  /
  7.  
  8.       OID        ID XC  XC
  9. --------- --------- --- -------
  10.    999999         1 SG9 SG3,SG9
  11.  
  12. SQL> 
  13.  
  14.  
Dec 11 '07 #5
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SQL> SELECT outlet_table.oid, user_table.id, outlet_table.xc,user_table.xc FROM
  3.   2  (select 1 AS id, 'XYZ' AS xname, 'SG3,SG9' AS xc FROM DUAL) user_table,
  4.   3  (SELECT 999999 AS oid, 'SG9' AS xc FROM DUAL) outlet_table
  5.   4  WHERE INSTR(user_table.xc,outlet_table.xc) > 0
  6.   5  /
  7.  
  8.       OID        ID XC  XC
  9. --------- --------- --- -------
  10.    999999         1 SG9 SG3,SG9
  11.  
  12. SQL> 
  13.  
  14.  

this is great! thank you it worked! =)
Dec 27 '07 #6
amitpatel66
2,367 Expert 2GB
this is great! thank you it worked! =)
You are welcome :)
Dec 27 '07 #7

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

Similar topics

4
by: Arne | last post by:
From: "Arne de Booij" <a_de_booij@hotmail.com> Subject: Comma delimited array into DB problems Date: 9. februar 2004 10:39 Hi, I have an asp page that takes input from a form on the previous...
4
by: Christine Forber | last post by:
I wonder if anyone knows of some javascript code to check a comma-delimited list of email addresses for basic formating. What I'm looking for is the javascript code to check a form field on form...
3
by: Elmo Watson | last post by:
I've been asked to develop a semi-automated type situation where we have a database table (sql server) and periodically, there will be a comma delimited file from which we need to import the data,...
2
by: A E | last post by:
Hi, I was wondering if there was a function that handles list elements of a comma delimited list? I need to be able to pass values as a comma delimited list, count the number of values, and...
2
by: Larry Williams | last post by:
Is there an easy way to convert a string of data to XML format without having to create the xml one field at a time? Sorry I'm a newbie and my xml knowledge is limited. I have tried to search...
1
by: John B. Lorenz | last post by:
I'm attempting to write an input routine that reads from a comma delimited file. I need to read in one record at a time, assign each field to a field array and then continue with my normal...
9
by: Wayne | last post by:
I have the following string: "smith", "Joe", "West Palm Beach, Fl." I need to split this string based on the commas, but as you see the city state contains a comma. String.split will spilt the...
9
by: Bernie Yaeger | last post by:
Is there a way to convert or copy a .xml file to a comma delimited text file using vb .net? Thanks for any help. Bernie Yaeger
4
by: JustSomeGuy | last post by:
Hi. I have a comma delimited text file that I want to parse. I was going to use fscanf from the C library but as my app is written in C++ I thought I'd use the std io stream library... My Text...
2
by: Ron | last post by:
so if my textbox is named textbox1 and my listbox is named ltsdisplay, for the button that would make this all happen I would just need to: ...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
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.