Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more

Go Back   Webmaster Forums - Webmaster forum for HTML, PHP, ASP, CSS and more > Web Programming > Databases - MySQL, SQL, Oracle, Access and others
User Name
Password

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 05-03-2007, 08:41 AM   #1 (permalink)
drew22299
Junior Member
 
Join Date: Mar 2006
Location: Wilts / Bristol
Posts: 54
Default Can anyone help me with this SQL query?

Hey,

I have a script written in asp and I have modified some of the SQL to search the database for specific things that I have specified in WHERE.

How would I write an SQL query in Php or asp to search the database based on the user input? for example, if the user types in the name of a town or city and make it search the fields in the database based on what they typed?

Thanks!
__________________
www.hotlista.co.uk
drew22299 is offline   Reply With Quote
Sponsored Links
Old 05-04-2007, 11:28 AM   #2 (permalink)
Krishnaswamy
Junior Member
 
Join Date: May 2007
Posts: 29
Default Re: Can anyone help me with this SQL query?

Your question is very general.

Assuming you have a SQL Server database, the best practice is to create a stored procedure. This procedure can be written in such a way at run time you provide, let us say, the Customer ID, then it will fetch from the database all iformation for that particular Customer. This can be done in PHP or ASP.

Select * from Customers
where Customer ID=?

This is generally the type of query you will be using and at run time you will type-in what the ? mark is.
Krishnaswamy is offline   Reply With Quote
Old 05-09-2007, 04:15 AM   #3 (permalink)
drew22299
Junior Member
 
Join Date: Mar 2006
Location: Wilts / Bristol
Posts: 54
Default Re: Can anyone help me with this SQL query?

I understand that and I know what the code needs to do but I don't know the syntax etc, which is why I posted a message on this forum so someone could write an example code.
__________________
www.hotlista.co.uk
drew22299 is offline   Reply With Quote
Old 06-08-2007, 11:44 AM   #4 (permalink)
Krishnaswamy
Junior Member
 
Join Date: May 2007
Posts: 29
Default Re: Can anyone help me with this SQL query?

This is a small tutorial for you on your query questions(no pun):
This is a simpel table called Student in your database with four columns, StudentID, SFName,SLName, and DateCertified:

1 Venkat Raman 1/1/1908 12:00:00 AM
9 Jay Krishnaswamy 4/3/1941 12:00:00 AM
22 Nicole Kidman 4/5/2000 12:00:00 AM
23 John Pollack 1/1/2000 12:00:00 AM
--------------------------
This is a simple well known "SELECT" query
----------------------------
select SFname, SLName
from Student
where StudentID='9'

This gives the result
Jay Krishnaswamy------------------------------
Create a stored proc (testing)which shows all data in the table:
create proc testing as
select SFName, SLName
from Student

--------------------------------
Now the code you wantedthis creates a stored procedure newTest)
create proc newTest
@idss nchar(20)
as
select SFName, SLName
from Student
where @idss=SFName

---------------
when you run the following command:
exec newTest 'Jay'
you will get:
Jay krishnaswamy

I hope this helps.

Jay
Krishnaswamy is offline   Reply With Quote
Old 07-27-2007, 05:10 AM   #5 (permalink)
QvnsQ
Mybuny.com
 
Join Date: Mar 2007
Posts: 1,331
Default Re: Can anyone help me with this SQL query?

so the problem already fixed??
__________________
Add This To / Social Bookmarks
R6K.NET: Free arcades
H7v Net : best place for all
High Rank Forum
Google pagerank give away!!
QvnsQ is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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

Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00



» Sponsors

» Links

» Affiliates
Web Hosting
Marketing Find
Merchant Select
SiteMap Builder
Host Compare
Dedicated Servers

» Links

» Sports Network
Paintball Forum
Football Forum
Hockey Forum
Golf Forum
Boxing Forum
Lacrosse Forum
Baseball Forum
SnowBoarding Forum
Soccer Forum
MMA Forum


All times are GMT -4. The time now is 08:04 AM.



LinkBacks Enabled by vBSEO 3.0.0 RC8
Webmaster Forums