Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Search Query Problem

Reply
Thread Tools

Search Query Problem

 
 
Simon Gare
Guest
Posts: n/a
 
      05-02-2007
Hi,

have a search.asp page with results.asp page drawing data from an SQL db,
problem is the user has to type the whole field value into the search box to
retrieve the value on results.asp, what I need is to type in just a few
characters e.g. at the moment to search for all pickups at Heathrow Terminal
1 the user has to type in

Heathrow Terminal 1

When really I just want them to type in

Heathrow or even Heath etc.

Query below

SELECT * FROM booking_form WHERE AirportStation LIKE '" +
Replace(BookingForm__varAirportStation, "'", "''") + "'


anyone help?

Simon
--
Simon Gare
The Gare Group Limited

website: www.thegaregroup.co.uk
website: www.privatehiresolutions.co.uk


 
Reply With Quote
 
 
 
 
michal
Guest
Posts: n/a
 
      05-02-2007
SELECT * FROM booking_form WHERE AirportStation LIKE ('%" +
Replace(BookingForm__varAirportStation, "'", "''") + "%')"

should do it

On 2 Mai, 10:01, "Simon Gare" <s...@simongare.com> wrote:
> Hi,
>
> have a search.asp page with results.asp page drawing data from an SQL db,
> problem is the user has to type the whole field value into the search box to
> retrieve the value on results.asp, what I need is to type in just a few
> characters e.g. at the moment to search for all pickups at Heathrow Terminal
> 1 the user has to type in
>
> Heathrow Terminal 1
>
> When really I just want them to type in
>
> Heathrow or even Heath etc.
>
> Query below
>
> SELECT * FROM booking_form WHERE AirportStation LIKE '" +
> Replace(BookingForm__varAirportStation, "'", "''") + "'
>
> anyone help?
>
> Simon
> --
> Simon Gare
> The Gare Group Limited
>
> website: www.thegaregroup.co.uk
> website: www.privatehiresolutions.co.uk



 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      05-02-2007
Simon Gare wrote on 02 mei 2007 in
microsoft.public.inetserver.asp.general:

> Hi,
>
> have a search.asp page with results.asp page drawing data from an SQL
> db, problem is the user has to type the whole field value into the
> search box to retrieve the value on results.asp, what I need is to
> type in just a few characters e.g. at the moment to search for all
> pickups at Heathrow Terminal 1 the user has to type in
>
> Heathrow Terminal 1
>
> When really I just want them to type in
>
> Heathrow or even Heath etc.
>
> Query below
>
> SELECT * FROM booking_form WHERE AirportStation LIKE '" +
> Replace(BookingForm__varAirportStation, "'", "''") + "'


With "LIKE" you only would have to add a wildcard character.

SELECT * FROM booking_form WHERE AirportStation LIKE '" +_
yourSearchInput + "%" + "'

=============

"Heathrow Te" + "%"

will select:

Heathrow Terminal 1
Heathrow Terminal 2
Heathrow Terminal 3
Heathrow Terminal 4
Heathrow Terminal 5 [?]


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
 
Reply With Quote
 
Simon Gare
Guest
Posts: n/a
 
      05-02-2007
Thanks all worked perfectly.

Simon


 
Reply With Quote
 
Simon Gare
Guest
Posts: n/a
 
      05-02-2007
Just came across a problem, when searching the date field it returns
nothing, current entry format is

dd/mm/yyyy hh:mm:ss
02/05/2007 10:26:00

when I search for 02/05/2007 nothing is returned even though I have the % in
place.

All other search criteria is working ok?

Simon


"Simon Gare" <> wrote in message
news:...
> Hi,
>
> have a search.asp page with results.asp page drawing data from an SQL db,
> problem is the user has to type the whole field value into the search box

to
> retrieve the value on results.asp, what I need is to type in just a few
> characters e.g. at the moment to search for all pickups at Heathrow

Terminal
> 1 the user has to type in
>
> Heathrow Terminal 1
>
> When really I just want them to type in
>
> Heathrow or even Heath etc.
>
> Query below
>
> SELECT * FROM booking_form WHERE AirportStation LIKE '" +
> Replace(BookingForm__varAirportStation, "'", "''") + "'
>
>
> anyone help?
>
> Simon
> --
> Simon Gare
> The Gare Group Limited
>
> website: www.thegaregroup.co.uk
> website: www.privatehiresolutions.co.uk
>
>



 
Reply With Quote
 
michal
Guest
Posts: n/a
 
      05-02-2007
i am not sure but i think that like is not working on data columns ...
you should be fine with
WHERE datCol = '02/05/2007'

On 2 Mai, 11:28, "Simon Gare" <s...@simongare.com> wrote:
> Just came across a problem, when searching the date field it returns
> nothing, current entry format is
>
> dd/mm/yyyy hh:mm:ss
> 02/05/2007 10:26:00
>
> when I search for 02/05/2007 nothing is returned even though I have the % in
> place.
>
> All other search criteria is working ok?
>
> Simon
>
> "Simon Gare" <s...@simongare.com> wrote in message
>
> news:...
>
>
>
> > Hi,

>
> > have a search.asp page with results.asp page drawing data from an SQL db,
> > problem is the user has to type the whole field value into the search box

> to
> > retrieve the value on results.asp, what I need is to type in just a few
> > characters e.g. at the moment to search for all pickups at Heathrow

> Terminal
> > 1 the user has to type in

>
> > Heathrow Terminal 1

>
> > When really I just want them to type in

>
> > Heathrow or even Heath etc.

>
> > Query below

>
> > SELECT * FROM booking_form WHERE AirportStation LIKE '" +
> > Replace(BookingForm__varAirportStation, "'", "''") + "'

>
> > anyone help?

>
> > Simon
> > --
> > Simon Gare
> > The Gare Group Limited

>
> > website: www.thegaregroup.co.uk
> > website: www.privatehiresolutions.co.uk- Zitierten Text ausblenden -

>
> - Zitierten Text anzeigen -



 
Reply With Quote
 
Simon Gare
Guest
Posts: n/a
 
      05-02-2007
but we retrieve the value from a querystring that is entered on a search
page

BookingForm__varID = Request.Querystring DATE2

TimeOfBooking LIKE '%" + Replace(BookingForm__varID, "'", "''") + "%'

but returns no values doesn't matter what format you put it in either, will
retrieve values when the format is correct though which is no good to us.

02/05/2007 11:02:35 etc




"michal" <> wrote in message
news: ups.com...
> i am not sure but i think that like is not working on data columns ...
> you should be fine with
> WHERE datCol = '02/05/2007'
>
> On 2 Mai, 11:28, "Simon Gare" <s...@simongare.com> wrote:
> > Just came across a problem, when searching the date field it returns
> > nothing, current entry format is
> >
> > dd/mm/yyyy hh:mm:ss
> > 02/05/2007 10:26:00
> >
> > when I search for 02/05/2007 nothing is returned even though I have the

% in
> > place.
> >
> > All other search criteria is working ok?
> >
> > Simon
> >
> > "Simon Gare" <s...@simongare.com> wrote in message
> >
> > news:...
> >
> >
> >
> > > Hi,

> >
> > > have a search.asp page with results.asp page drawing data from an SQL

db,
> > > problem is the user has to type the whole field value into the search

box
> > to
> > > retrieve the value on results.asp, what I need is to type in just a

few
> > > characters e.g. at the moment to search for all pickups at Heathrow

> > Terminal
> > > 1 the user has to type in

> >
> > > Heathrow Terminal 1

> >
> > > When really I just want them to type in

> >
> > > Heathrow or even Heath etc.

> >
> > > Query below

> >
> > > SELECT * FROM booking_form WHERE AirportStation LIKE '" +
> > > Replace(BookingForm__varAirportStation, "'", "''") + "'

> >
> > > anyone help?

> >
> > > Simon
> > > --
> > > Simon Gare
> > > The Gare Group Limited

> >
> > > website: www.thegaregroup.co.uk
> > > website: www.privatehiresolutions.co.uk- Zitierten Text ausblenden -

> >
> > - Zitierten Text anzeigen -

>
>



 
Reply With Quote
 
Mike Brind
Guest
Posts: n/a
 
      05-02-2007
Michal is correct. LIKE doesn't work with datetime. You will have to use
Between to find datetimes in a range. If you want to find items with
today's date, your range will be from 02/05/2007 00:00:00 to 02/05/2007
23:59:59.

--
Mike Brind

"Simon Gare" <> wrote in message
news:...
> Just came across a problem, when searching the date field it returns
> nothing, current entry format is
>
> dd/mm/yyyy hh:mm:ss
> 02/05/2007 10:26:00
>
> when I search for 02/05/2007 nothing is returned even though I have the %
> in
> place.
>
> All other search criteria is working ok?
>
> Simon
>
>
> "Simon Gare" <> wrote in message
> news:...
>> Hi,
>>
>> have a search.asp page with results.asp page drawing data from an SQL db,
>> problem is the user has to type the whole field value into the search box

> to
>> retrieve the value on results.asp, what I need is to type in just a few
>> characters e.g. at the moment to search for all pickups at Heathrow

> Terminal
>> 1 the user has to type in
>>
>> Heathrow Terminal 1
>>
>> When really I just want them to type in
>>
>> Heathrow or even Heath etc.
>>
>> Query below
>>
>> SELECT * FROM booking_form WHERE AirportStation LIKE '" +
>> Replace(BookingForm__varAirportStation, "'", "''") + "'
>>
>>
>> anyone help?
>>
>> Simon
>> --
>> Simon Gare
>> The Gare Group Limited
>>
>> website: www.thegaregroup.co.uk
>> website: www.privatehiresolutions.co.uk
>>
>>

>
>



 
Reply With Quote
 
Simon Gare
Guest
Posts: n/a
 
      05-02-2007
ok, so if I want to find all entries an the results page with the date
specified in the querystring which is entered manually by the user on the
search page how do I go about that? do I use 2 BETWEEN statements ie

Select * FROM BookingForm WHERE DATE2 BETWEEN Request.Querystring("DATE2")
and BETWEEN Request.Querystring("DATE2")

something like that?

Simon


"Mike Brind" <> wrote in message
news:...
> Michal is correct. LIKE doesn't work with datetime. You will have to use
> Between to find datetimes in a range. If you want to find items with
> today's date, your range will be from 02/05/2007 00:00:00 to 02/05/2007
> 23:59:59.
>
> --
> Mike Brind
>
> "Simon Gare" <> wrote in message
> news:...
> > Just came across a problem, when searching the date field it returns
> > nothing, current entry format is
> >
> > dd/mm/yyyy hh:mm:ss
> > 02/05/2007 10:26:00
> >
> > when I search for 02/05/2007 nothing is returned even though I have the

%
> > in
> > place.
> >
> > All other search criteria is working ok?
> >
> > Simon
> >
> >
> > "Simon Gare" <> wrote in message
> > news:...
> >> Hi,
> >>
> >> have a search.asp page with results.asp page drawing data from an SQL

db,
> >> problem is the user has to type the whole field value into the search

box
> > to
> >> retrieve the value on results.asp, what I need is to type in just a few
> >> characters e.g. at the moment to search for all pickups at Heathrow

> > Terminal
> >> 1 the user has to type in
> >>
> >> Heathrow Terminal 1
> >>
> >> When really I just want them to type in
> >>
> >> Heathrow or even Heath etc.
> >>
> >> Query below
> >>
> >> SELECT * FROM booking_form WHERE AirportStation LIKE '" +
> >> Replace(BookingForm__varAirportStation, "'", "''") + "'
> >>
> >>
> >> anyone help?
> >>
> >> Simon
> >> --
> >> Simon Gare
> >> The Gare Group Limited
> >>
> >> website: www.thegaregroup.co.uk
> >> website: www.privatehiresolutions.co.uk
> >>
> >>

> >
> >

>
>



 
Reply With Quote
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      05-02-2007
Simon Gare wrote:
> Just came across a problem, when searching the date field it returns
> nothing, current entry format is
>
> dd/mm/yyyy hh:mm:ss
> 02/05/2007 10:26:00
>

http://www.aspfaq.com/show.asp?id=2313 vbscript
http://www.aspfaq.com/show.asp?id=2040 help with dates
http://www.aspfaq.com/show.asp?id=2260 dd/mm/yyy confusion
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
| SEO , Search Engine Optimizer, SEARCH OPtiMIzAtIoN with SeaRch OPtiMizer optimizer.seo@gmail.com Digital Photography 0 04-22-2007 04:20 AM
Trying to query the Address table data of AdventureWorks database from Query Analyzer - need help! Learner ASP .Net 1 01-30-2006 08:58 PM
Build dynamic sql query for JSTL <sql:query> Anonymous Java 0 10-13-2005 10:01 PM
search within a search within a search - looking for better way...my script times out Abby Lee ASP General 5 08-02-2004 04:01 PM
Query in Index Server: @filename search problem abcdef ASP General 0 10-07-2003 02:31 PM



Advertisments