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

SQL question with Autocomplete

Hi,

I'm working on a little autocomplete functionality with the AJAX
toolkit. I like to the following,

Take the following 2 SQLs
SELECT NAME FROM COUNTRIES WHERE NAME LIKE '%TORONTO%' (would return
false)
SELECT NAME FROM CITIES WHERE NAME LIKE '%TORONTO%' (would return
true)

I like to have a stored procedure that does this. How do you write the
IF condition. Bascially I want it to first check the countries table
and if not matches there , next go to the CITIES table and check it
there? or is there a way to check both tables at once and return only
a single resultset combining both matches in COUNTRIES and CITIES
table? (in a single column 'Name'?)

Thank you
M.
Mar 18 '08 #1
2 1140
Not really sure what you're after, but have a look at this;

IF EXISTS (SELECT 1 FROM Countries WHERE Name LIKE '%Toronto%')
SELECT 1
ELSE IF EXISTS (SELECT 1 FROM Cities WHERE Name LIKE '%Toronto%')
SELECT 1
ELSE
SELECT 0

"mazdotnet" <ma*******@gmail.comwrote in message
news:71**********************************@d21g2000 prf.googlegroups.com...
Hi,

I'm working on a little autocomplete functionality with the AJAX
toolkit. I like to the following,

Take the following 2 SQLs
SELECT NAME FROM COUNTRIES WHERE NAME LIKE '%TORONTO%' (would return
false)
SELECT NAME FROM CITIES WHERE NAME LIKE '%TORONTO%' (would return
true)

I like to have a stored procedure that does this. How do you write the
IF condition. Bascially I want it to first check the countries table
and if not matches there , next go to the CITIES table and check it
there? or is there a way to check both tables at once and return only
a single resultset combining both matches in COUNTRIES and CITIES
table? (in a single column 'Name'?)

Thank you
M.

Mar 18 '08 #2
a single resultset combining both matches in COUNTRIES and CITIES
table? (in a single column 'Name'?)
SELECT NAME FROM COUNTRIES WHERE NAME LIKE '%TORONTO%'
UNION
SELECT NAME FROM CITIES WHERE NAME LIKE '%TORONTO%'
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"mazdotnet" <ma*******@gmail.comwrote in message
news:71**********************************@d21g2000 prf.googlegroups.com...
Hi,

I'm working on a little autocomplete functionality with the AJAX
toolkit. I like to the following,

Take the following 2 SQLs
SELECT NAME FROM COUNTRIES WHERE NAME LIKE '%TORONTO%' (would return
false)
SELECT NAME FROM CITIES WHERE NAME LIKE '%TORONTO%' (would return
true)

I like to have a stored procedure that does this. How do you write the
IF condition. Bascially I want it to first check the countries table
and if not matches there , next go to the CITIES table and check it
there? or is there a way to check both tables at once and return only
a single resultset combining both matches in COUNTRIES and CITIES
table? (in a single column 'Name'?)

Thank you
M.

Mar 18 '08 #3

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

Similar topics

4
by: bc | last post by:
Hi, Is it possible to detect if the IE autocomplete function in a current context such as a textbox is activated (ie. dropdown with previously entered info is visible)? Problem: I use a script...
2
by: scorp7355 | last post by:
I was wondering if there is some other way to turn autocomplete off besides using "autocomplete=off", using a meta tag or something similar. It would be great if there is some way to turn it off...
40
by: Alex | last post by:
Hello, does anybody know how to turn off the autocomplete feature for a certain text field? I am aware of the "autocomplete" attribute, but I have seen other implementions achieving it...
8
by: moondaddy | last post by:
I have a form for entering a user's address and all fields have a required validating control associated with them and the error msg for each field displays right next to it. The normal behavior...
1
by: thubba2000 | last post by:
We have a web application developed using IBuySpy. In older versions, Autocomplete on all web forms works. In our latest version, it stopped working on all clients. I have gone through all the...
1
by: rbg.net | last post by:
I know that there is a autocomplete property for the HTML "INPUT type=text" control which if set to OFF, disables autocomplete of the input textbox (doesn't remember previously entered values) ...
5
by: Andrus | last post by:
I'm creating a database Winforms application using VCS Express 2005 I have some large lookup tables (may be up to 500000 records) which contains name and id and are stored in sql server. I...
1
by: wkerplunk | last post by:
Below is what I have build with several different languages. It works great but I need help, I am stuck. When you click on an item in the dropdown autocomplete div it does a mousedown function...
3
by: groups2 | last post by:
When you press the down key while in an input field the default behavior for some event creates a dropdown of the previously input text. What event creates that behavior and how do I stop it ? ...
1
by: =?Utf-8?B?UmV5?= | last post by:
I have a textbox and linked that with the autocomplete extender I have created the webservice and the WebMethod and returns a ToArray to the textbox. Everything works when I type normal string...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.