473,400 Members | 2,145 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,400 software developers and data experts.

like function on a column

4
Hi,

I have 2 tables - Companies and List.

The table List has a Org column. I am trying to look for companies in the Companies table that are like the names in the Org column from the List table.

Do I need a loop function for this? and if so, can someone please help me to write the function?

Thanks,
ddk
Mar 10 '08 #1
7 1311
amitpatel66
2,367 Expert 2GB
Hi,

I have 2 tables - Companies and List.

The table List has a Org column. I am trying to look for companies in the Companies table that are like the names in the Org column from the List table.

Do I need a loop function for this? and if so, can someone please help me to write the function?

Thanks,
ddk
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT c.* from companies c, list l WHERE c.company LIKE '%l.org%'
  3. /
  4.  
  5. SELECT c.* from companies c, list l WHERE INSTR(c.company,l.org) > 0
  6. /
  7.  
  8.  
Mar 10 '08 #2
ddk
4
Try this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT c.* from companies c, list l WHERE c.company LIKE '%l.org%'
  3. /
  4.  
  5. SELECT c.* from companies c, list l WHERE INSTR(c.company,l.org) > 0
  6. /
  7.  
  8.  

this is returning more results than it should -
for an org name like 3M% from List, it is returning 3M, 3COM etc.. from the Companies table
Mar 10 '08 #3
amitpatel66
2,367 Expert 2GB
this is returning more results than it should -
for an org name like 3M% from List, it is returning 3M, 3COM etc.. from the Companies table
Both the queries returning more than the expected for 3M%?

For org = 3M%, it should return records atarting with 3M followed by any number of characters or numbers.
Mar 10 '08 #4
ddk
4
The Instr query: I am using the query you sent over. For an Org called 3M from the List table, I see 3M, 3COM being returned in the result set from the Companies table.
Mar 10 '08 #5
amitpatel66
2,367 Expert 2GB
The Instr query: I am using the query you sent over. For an Org called 3M from the List table, I see 3M, 3COM being returned in the result set from the Companies table.
Did you try the other one??
Mar 10 '08 #6
ddk
4
you know, it actually worked!!

Thanks a ton!
Mar 10 '08 #7
amitpatel66
2,367 Expert 2GB
you know, it actually worked!!

Thanks a ton!
Even I was wondering that why it did not work properly...
Anyways, you can post back in case of any further queries.
Mar 11 '08 #8

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

Similar topics

5
by: | last post by:
Is it possible to extend this function to dynamically create a combo boxes from the db table....How would do this...I tried passing a 'Select' type to the function but got a blank entry....Any...
13
by: Sheperd | last post by:
Hey everyone, I have this browser detect script and the validator is having problems with it, im trying to validate a page for XHTML 1.0 Transitional If you have any ideas or suggestions they...
18
by: Bill Smith | last post by:
The initial row is inserted with the colPartNum column containing a valid LIKE pattern, such as (without the single quotes) 'AB%DE'. I want to update the column value with the results of a query...
7
by: junk1 | last post by:
I am running a query from a Java app via the IBM type 4 driver back to MF DB2 and am getting a strange result. Basically my statement is SELECT BLAH WHERE NAME LIKE ? ....and I pass in...
10
by: David Garamond | last post by:
Reading the archives and the FAQ, it seems to be implied that LIKE can use index (and ILIKE can't; so to do case-insensitive search you need to create a functional index on LOWER(field) and say:...
8
by: Roland Hall | last post by:
In Access you use "*" + + "*", + can be replaced with & Calling a parameterized query in Access requires % be used in place of *, however, all that I have read show dynamic SQL passed to Access: ...
7
by: jknaty | last post by:
I'm trying to create a function that splits up a column by spaces, and I thought creating a function that finds the spaces with CHARINDEX and then SUBSTRING on those values would an approach. I...
1
by: BertDick | last post by:
I'm trying to use the IRR function in Ms Access using the code below. Function MyIRR(mygroupid, myguess) as double Dim Values(4) as double' an array with 5 elements Dim x dim rs as...
8
by: mguy27 | last post by:
We have about 2 dozen security officers who patrol about 120 buildings. They find defective or unlocked doors and write a "Trouble Report" on the door. This card gets turned in, where I have designed...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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,...
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...
0
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...
0
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,...

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.