Gossamer Forum
Home : General : Databases and SQL :

searching...

Quote Reply
searching...
   

My Database column include Name,Designation,Department,Telphone ..etc

may i know how to make the sql select statement to search for the above?

currently i tried this but only allow me to search with Name.

strSQL = "SELECT * FROM Info WHERE INSTR(Info.Name,'" & strSearch & "')"



Thanks
Quote Reply
Re: [gnehs] searching... In reply to
Have you tried LIKE?

SELECT * FROM Info WHERE Name LIKE '%words to find%'

Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] searching... In reply to
Ermm....

wat i mean is
SELECT * FROM Info WHERE Name,Department,Telephone...blah blah = to my search
Quote Reply
Re: [gnehs] searching... In reply to
Best way to do this kinda thing is by building up your search. i.e;

$var = "SELECT * FROM Info WHERE Title LIKE \'%$search_string%\' OR Department LIKE \'%$search_string%\' OR Telephone LIKE \'%$search_string%\'";

Does that make sense? That should work fine.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] searching... In reply to
What language is this?

I am using SQL and ASP only....
Quote Reply
Re: [gnehs] searching... In reply to
Quote:
What language is this?
Its SQL (Structured Query Language).
If your going to do any serious db work then you will need to learn it.

Here are a few qood tutorials that I picked off google which may help-

http://www.w3schools.com/sql/sql_intro.asp
http://www.1keydata.com/sql/sql.html
http://www.baycongroup.com/tocsql.htm
http://www.firstsql.com/tutor.htm
http://www.sqlcourse.com/

Bob
http://totallyfreeads.com.au
Quote Reply
Re: [gnehs] searching... In reply to
Its Perl/MySQL Wink Shouldn't be hard to transpose it though. Something like;

strSQL = "SELECT * FROM Info WHERE Title LIKE \'%$search_string%\' OR Department LIKE \'%$search_string%\' OR Telephone LIKE \'%$search_string%\'"

I'm not an ASP programmer (as you may be able to tell), so I'm not sure on the structuring of variables.... The idea is there though.

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] searching... In reply to
Quote:
Its Perl/MySQL

Doesn't look like it. strSQL isn't a perl variable and I'm not sure why you are escaping those single quotes.

Perhaps you need to decide what language you are going to answer in, before answering.
Quote Reply
Re: [Paul] searching... In reply to
Quote:
Doesn't look like it. strSQL isn't a perl variable and I'm not sure why you are escaping those single quotes.

Perhaps you need to decide what language you are going to answer in, before answering.


Perhaps you need to read the entire thread CORRECTLY before accusing me of being wrong. The code I provided in the below post WAS a Perl/MySQL query string.[/quote]Best way to do this kinda thing is by building up your search. i.e;

$var = "SELECT * FROM Info WHERE Title LIKE \'%$search_string%\' OR Department LIKE \'%$search_string%\' OR Telephone LIKE \'%$search_string%\'";

Does that make sense? That should work fine.[/quote]
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Quote Reply
Re: [Andy] searching... In reply to
Mmm I don't believe I accused you of anything. I said it didn't look like perl...that's not an accusation.

This still applies...

>>
I'm not sure why you are escaping those single quotes.
<<
Quote Reply
Re: [Paul] searching... In reply to
The way it came over, was that you were saying I didn't know what I was talking about (which is true to the sense that I don't know ASP).... but;

Quote:
This still applies...

>>
I'm not sure why you are escaping those single quotes.
<<

True Tongue

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!