About Search Query

Aug 2, 2005

I would like to write query which can1.  ignore whether the search keyword is Upper case or lower Case2. deal with tense or verb form related  problem    eg. comparing --> also search compareAny Idea

View 9 Replies


ADVERTISEMENT

Help W/ Stored Procedure? - Full-text Search: Search Query Of Normalized Data

Mar 29, 2008

 Hi -  I'm short of SQL experience and hacking my way through creating a simple search feature for a personal project. I would be very grateful if anyone could help me out with writing a stored procedure. Problem: I have two tables with three columns indexed for full-text search. So far I have been able to successfully execute the following query returning matching row ids:  dbo.Search_Articles        @searchText varchar(150)        AS    SELECT ArticleID     FROM articles    WHERE CONTAINS(Description, @searchText) OR CONTAINS(Title, @searchText)    UNION    SELECT ArticleID     FROM article_pages    WHERE CONTAINS(Text, @searchText);        RETURN This returns the ArticleID for any articles or article_pages records where there is a text match. I ultimately need the stored procedure to return all columns from the articles table for matches and not just the StoryID. Seems like maybe I should try using some kind of JOIN on the result of the UNION above and the articles table? But I have so far been unable to figure out how to do this as I can't seem to declare a name for the result table of the UNION above. Perhaps there is another more eloquent solution? Thanks! Peter 

View 3 Replies View Related

SQL 2000 MS Search: Boolean Search Doesn't Work When Search By Phrase

Aug 9, 2006

I'm just wonder if this is a bug in MS Search or am I doing something wrong.

I have a query below

declare @search_clause varchar(255)

set @Search_Clause = ' "hepatitis b" and "hepatocellular carcinoma"'

select * from results

where contains(finding,@search_clause)

I don't get the correct result at all.

If I change my search_clause to "hepatitis" and "hepatocellular carcinoma -- without the "b"

then i get the correct result.

It seems MS Search doesn't like the phrase contain one letter or some sort or is it a know bug?

Anyone know?

Thanks

View 3 Replies View Related

SQL Search Query Help!

Sep 11, 2004

I am having hard time figuring out what query I need to write.


What I want to do is, when users enter a word into a textbox, it displays results similar to it. Something similar to what Google does.

This is what I am doing now.
For example I will use "John Smith"

1. I get the first 3 letters of the string "Joh"
2. Get the last letter of the string "h"
3. and this is what I search for "Joh%h%"

This works, but I still have some problems. I want to be able to search like Google, where it recognizes words. Does anybody know how I can do this, or send me a link with an example?

Thank you

View 3 Replies View Related

Search Query

Aug 16, 2005

hi all
I have the follwoing search page:
several text boxes in case they want to search for SSN, first name,
last name, zipcode, several dorpdown lists, and a set of radio buttons.
I want to create the SQL statement to display the results
I am checking if any of the text boxes has anything in it, if yes add
"where something = value" to the query, if not then skip... now let's
say it goes through textbox 1 and finds it empty, so it jumps to the
second one it find info in it, how do I deal with the "and" clause
within the query?
any tips are fine.. (im using c#)
thanks

View 7 Replies View Related

Need Query Help For Search

Feb 28, 2006

I am writing a small search feature to return a list of companies whose name "Begins with" a certain string (up to 5 chars) provided by the user via a textbox.  I want the results to only return results that begin with the letter/letters specified.  Below I will put the code that I came up with that isn't working quite how I expected.  I am new to this so any assistance and short explanation would be very much apperciated.
sql="SELECT distinct cm.cmmst_id, cm.cm_compno, cm.cm_cname1 + ' ' + cm.cm_cname2 AS cm_cname1, cm_tele, cm_fax, cm_s16 "
sql=sql & "FROM cmmst cm "
sql=sql & "WHERE cm_cname1 + ' ' + cm_cname2 LIKE '%" companyNameBegins,"'","''") & "%' " sql=sql & "AND (cm_mbtyp='M' OR cm_mbtyp='SUBDIV') " sql=sql & "ORDER BY cm_s16 DESC, cm_cname1 ASC"
companyNameBegins is the string passed in by the user
 
Thanks,
Zoop

View 2 Replies View Related

SQL Search Query

Mar 27, 2001

Hello-

I am having a difficult time figuring out the differences between the following 2 queries. The first query ( which should return around 8000 records) when run against a Sql7 DB with 70000 records will always timeout (timeout set at 30 secs), but the 2nd query will return the correct amount of records ( about 8000 ) in under 8 secs.

Could someone shed some light on this for me?

Thank you
Robert

******Start Query 1******
Select Lot, Title, UserId, HighBidder, HighBid,
BidTimes, DateIn, EndDate, Price, Category, Options,
Reserve, StartDate From Auctions A Where (
((title LIKE '%STUB%' )) or ((description LIKE '%STUB%' ))
) And (Status In ('A', 'P') Or (Status In ('B', 'C')
And EndDate >= '02/25/2001')
) And ((A.Reserve > A.Price And A.Reserve Between 0
And 999999.99)
Or (A.Price Between 0 And 999999.99))
Order By Lot Asc




*****End Query 1*****

******Start Query 2******
Select Lot, Title, UserId, HighBidder, HighBid,
BidTimes, DateIn, EndDate, Price, Category, Options,
Reserve, StartDate From
(Select Lot, Title, UserId, HighBidder, HighBid,
BidTimes, DateIn, EndDate, Price, Category, Options,
Reserve, StartDate,Description From Auctions A Where
(A.Status In ('A', 'P')

Or (A.Status In ('B', 'C') And
A.EndDate >= '02/25/2001')

) And ((A.Reserve > A.Price And A.Reserve Between 0
And 999999.99)
Or (A.Price Between 0 And 999999.99))
) as X
Where (

( (title LIKE '%STUB%' ))


or ( (description LIKE '%STUB%' ))



)
Order By Lot Asc

******End Query 2******

View 1 Replies View Related

Need Help On Search Query.

Sep 6, 2007



Hello All!

I'm building a serch page on website. It basicly searches 2 tables. Right now, the way I have it so the user can enter a value in one of the fields, and not the others. And it will return the value. For example, put in '34' in the age field, it will return all people with 34. Now if you add 'Jones' to the last name field, it will return all people with the age of 34, and all people with Jones.

But what if I want it so it returns only the people with the age 34, and Jones. But leave the other fields blank. The later than add 'Jim' to the first name, so now it will return 34, jones, jim. I tried to use the AND operator, but then it requires that field to be filled. Here is my code.

ALTER PROCEDURE [dbo].[SrchActiveII]

@FName nvarchar(50)=NULL,
@LName nvarchar(50)=NULL,
@DOB nvarchar(50)=NULL,
@Acct nvarchar(50)=NULL,
@Login nvarchar(50)=NULL,
@Status nvarchar(50)=NULL,
@Rmark nvarchar(255)=NULL,
@Room nvarchar(50)=NULL,
@Age nvarchar(50)=NULL,
@Type nvarchar(50)=NULL,
@Misc bit = NULL
AS
BEGIN
SELECT Active_Orders.First_Name, Active_Orders.Last_Name, Active_Orders.Account_Number, Order_Status.Status, Active_Orders.Remarks,
Locations.Loct_Desc, Active_Orders.Rm_Desc, Active_Orders.Age, Active_Orders.Type, Active_Orders.Stat,
Active_Orders.Order_ID, Active_Orders.Login, Active_Orders.Misc
FROM Active_Orders INNER JOIN
Order_Status ON Active_Orders.Status_ID = Order_Status.Status_ID INNER JOIN
Locations ON Active_Orders.Location_ID = Locations.Location_ID
WHERE (Active_Orders.First_Name =@FName) OR (First_Name IS NULL) OR
(Active_Orders.Last_Name =@Lname) OR (Last_Name IS NULL) OR
(Active_Orders.DOB = @DOB) OR (DOB IS NULL) OR
(Active_Orders.Account_Number = @Acct) OR (Account_Number IS NULL) OR
(Order_Status.Status = @Status) OR (Status IS NULL) OR
(Active_Orders.Remarks = @Rmark) OR (Remarks IS NULL) OR
(Active_Orders.Rm_Desc = @Room) OR (Rm_Desc IS NULL) OR
(Active_Orders.Age = @Age) OR (Age IS NULL) OR
(Active_Orders.Type = @Type) OR ([Type] IS NULL) OR
(Active_Orders.Login = @Login) OR ([Login] IS NULL) OR
(Active_Orders.Misc = @Misc) OR (Misc IS NULL)
END

Thanks!

Rudy

View 7 Replies View Related

Need Help In Search Query...

Apr 9, 2007

Hi,

I am making a search query for jobs site. I have a situation that if user type following string in my search box:



Web Developer Designer ISF New York



It should display all jobs conatins any one of given words. following are columns in my jobs table: (Query will be applied on Location, Title, Description, Company fields)








Jobs


JobID




PostedDate


Company


URL


Location


Title


Description


Contact







please help me what will be the query.

Thanks,

Bye.

View 7 Replies View Related

Simple Search Query

Mar 16, 2007

Hi,

 

I'm writing
small search engine for my page. I need SQL query that could do this:

 

Source:

 

tblColours

------------

Red

GreenRed

White Red

Yellow

Blue Green

Yellow RedF

 

Search
string: Red

 

Required
results:

 

Red

White Red

Yellow RedF

 

As you can
see I need all occurrences of word Red and word Red* but I don’t need *Red or
*Red* so I can't use LIKE %Red% :(.

 

P.S. Sorry
for my English.

Fizikas.

View 1 Replies View Related

Sql Query To Search In Two Tables

Jun 25, 2007

 i have two tables,
Opportunity

[OpporID] [numeric](18, 0) IDENTITY (1000, 1) NOT NULL ,
[OpportunityID] [varchar] (16) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[OpportunityTypeID] [numeric](10, 0) NOT NULL ,
[SLABased] [int] NOT NULL ,
[LoginID] [nvarchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[DateCreated] [datetime] NOT NULL ,
[AccountID] [int] NOT NULL ,
[GeographyID] [int] NOT NULL ,
[VerticalID] [int] NOT NULL ,
[BDMID] [int] NOT NULL ,
[Probability] [int] NOT NULL ,
[PASStatus] [int] NULL ,
[InsertedDate] [datetime] NULL ,
[InsertedBy] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[UpdatedDate] [datetime] NULL ,
[UpdatedBy] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[UpdatedFlag] [int] NULL

and SKILL
[SkillNo] [numeric](18, 0) IDENTITY (1, 1) NOT NULL ,
[OpportunityID] [numeric](18, 0) NOT NULL ,
[OrderId] [numeric](18, 0) NOT NULL ,
[PracticeID] [int] NULL ,
[SkillID] [int] NOT NULL ,
[NoOfPeople] [int] NOT NULL ,
[Clientinterview] [int] NOT NULL ,
[Location] [int] NOT NULL ,
[JDAttached] [int] NOT NULL ,
[JDFilePath] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[Status] [int] NULL ,
[Experience] [int] NULL ,
[InsertedDate] [datetime] NULL ,
[InsertedBy] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,
[UpdatedDate] [datetime] NULL ,
[UpdatedBy] [varchar] (50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL ,
[UpdatedFlag] [int] NULL ,
[GeoLocation] [int] NULL
)

i want to make a stored procedure for custom search on these two tables
with the following fields given to the user as an option to make his
choice..
from opportunity table -
OpportunityTypeID,SLABased,AccountID ,
GeographyID,
VerticalID,
BDMID,
Probability

and from skill table
SkillID, Location, GeoLocation

and return all the fields of opportunity table.

Can some make the stored procedure for me..

thanks a lot.

View 3 Replies View Related

Table And Search Query - Help Me Please.

Oct 16, 2007

Hi!In short description I want to make table with Articles and search Query for this table like there is search engine at templatemonster.com with templates and categories. Basicly I have table:- id - cat_name- 1 - Software- 2 - Hardware- 3 - Games- 4 - Internet- 5 - Events etc.And for example Article is in Software, Games and Events category, "1,3,5".Now user select to show articles in Games and Events categories, so "3,4,5"How write this search query? I don't have idea. 

View 2 Replies View Related

Best Query/Search Method

Nov 5, 2007

Hi,
I'm wondering about the following:
I have come across an InfoPath Forms application who's code is scripted in javascript and who's data seems to be in XML files.An analyst at that company told me they suspect the data is ALSO in SQL Server... somewhere.  They can't seem to find it though.  I havereviewed the .js code and some methods are called for which I can find no source.  I believe those methods execute OK because they're foundinside some DLL.
I'm thinking I would enter a new record using the form in InfoPath using some datavalue that I can expect will be unique.. like a lastname who's first three chars is ZZZ or something like that.  Subsequently, I'd search each column in each table in each DB on the server to see if I can locate it somewhere.
So, my question is what is the best approach for this?  I have access to the db, table and column names.  I know I can write a small vb.net piece of code to execute my search.  But, is there some better way using some sql procedure (or using the full text catalog) instead or any other tool(s)?  
Thanks in advance for your advise.
Stewart
 
 

View 3 Replies View Related

Help Needed In SQL Query Search!

Aug 2, 2005

Hi everyone,
I'm trying to implement SQL Server database search. The details are:-1. I have table called EMPLOYEE has FNAME,LNAME etc cols.2. User might look for any employee using either FNAME or LNAME3. I have search box in asp.net where user could enter search stringThe sample data:FNAME       LNAMEabc         georgedef         georgerkis        litarose        lita
The query i wrote:SELECT * FROM EMPLOYEE WHERE lname like '%' + searchArg + '%'My problem is:-1. let's say user is looking for employee "george"; In search string instead of typing actual word "george", user could type "jeorge"; because the name pronounce or sounds like similar.Same thing with user could type "leta" instead of "lita". Again these are all similar sounds.
When you look for "jeorge" in GOOGLE; it says "did you mean george"; i would like implement something like that. somewhere i saw SOUNDEX would do what i am looking for; but i no luck for me.
Is this possible anyway in T-SQL or Fulltext search.
Your help is greatly appreciated.
ThanksBob

View 1 Replies View Related

Upgrading A Search Query

Dec 6, 2005

 
i have an sp that does not use full text searching in SQL 2000 i was wondering if someone could point me in the right direction of changing/upgrading this to a full text search? would you recommend upgrading the search sp? the following is the sp i have(it uses a function to count the number of words):CREATE PROCEDURE SearchCatalog (@PageNumber tinyint,@ProductsOnPage tinyint,@HowManyResults smallint OUTPUT,@AllWords bit,@Word1 varchar(15) = NULL,@Word2 varchar(15) = NULL,@Word3 varchar(15) = NULL,@Word4 varchar(15) = NULL,@Word5 varchar(15) = NULL)AS
/* Create the temporary table that will contain the search results */CREATE TABLE #SearchedProducts(RowNumber SMALLINT NOT NULL IDENTITY(1,1), ProductID INT, Name VARCHAR(100), Description VARCHAR(1000), Price MONEY, ImagePath VARCHAR(100), Rank INT, ImageALT VARCHAR(100), ArtistName VARCHAR(50), Stock INT, SearchCoverQuality INT, SearchAlbumQuality INT)
/* Populate #SearchedProducts for an any-words search */IF @AllWords = 0    INSERT INTO #SearchedProducts           (ProductID, Name, Description, Price, ImagePath, ImageALT, ArtistName, Stock, SearchCoverQuality, SearchAlbumQuality, Rank)   SELECT Product.ProductID, Product.Name, Product.Description, Product.Price, Product.ImagePath,            Product.ImageALT, Artist.ArtistName, Product.Stock, AlbumSingleDetails.CoverQualityID, AlbumSingleDetails.QualityID,          3*dbo.WordCount(@Word1, Name)+dbo.WordCount(@Word1, Description)+dbo.WordCount(@Word1, ArtistName)+          3*dbo.WordCount(@Word2, Name)+dbo.WordCount(@Word2, Description)+dbo.WordCount(@Word2, ArtistName)+          3*dbo.WordCount(@Word3, Name)+dbo.WordCount(@Word3, Description)+dbo.WordCount(@Word3, ArtistName)+          3*dbo.WordCount(@Word4, Name)+dbo.WordCount(@Word4, Description)+dbo.WordCount(@Word4, ArtistName)+          3*dbo.WordCount(@Word5, Name)+dbo.WordCount(@Word5, Description)+dbo.WordCount(@Word5, ArtistName)          AS TotalRank   FROM Product INNER JOIN (Artist INNER JOIN AlbumSingleDetails ON Artist.ArtistID = AlbumSingleDetails.ArtistID) ON Product.ProductID = AlbumSingleDetails.ProductID   ORDER BY TotalRank DESC  
/* Populate #SearchedProducts for an all-words search */IF @AllWords = 1    INSERT INTO #SearchedProducts           (ProductID, Name, Description, Price, ImagePath, ImageALT, ArtistName, Stock, SearchCoverQuality, SearchAlbumQuality, Rank)   SELECT Product.ProductID, Product.Name, Product.Description, Product.Price, Product.ImagePath,   Product.ImageALT, Artist.ArtistName, Product.Stock, AlbumSingleDetails.CoverQualityID, AlbumSingleDetails.QualityID,          (3*dbo.WordCount(@Word1, Name)+dbo.WordCount(@Word1, Description)+dbo.WordCount(@Word1, ArtistName)) *          CASE              WHEN @Word2 IS NULL THEN 1              ELSE 3*dbo.WordCount(@Word2, Name)+dbo.WordCount(@Word2, Description)+dbo.WordCount(@Word2, ArtistName)          END *          CASE              WHEN @Word3 IS NULL THEN 1              ELSE 3*dbo.WordCount(@Word3, Name)+dbo.WordCount(@Word3, Description)+dbo.WordCount(@Word3, ArtistName)          END *          CASE              WHEN @Word4 IS NULL THEN 1              ELSE 3*dbo.WordCount(@Word4, Name)+dbo.WordCount(@Word4, Description)+dbo.WordCount(@Word4, ArtistName)          END *          CASE              WHEN @Word5 IS NULL THEN 1              ELSE 3*dbo.WordCount(@Word5, Name)+dbo.WordCount(@Word5, Description)+dbo.WordCount(@Word5, ArtistName)          END          AS TotalRank   FROM Product INNER JOIN (Artist INNER JOIN AlbumSingleDetails ON Artist.ArtistID = AlbumSingleDetails.ArtistID) ON Product.ProductID = AlbumSingleDetails.ProductID   ORDER BY TotalRank DESC
/* Save the number of searched products in an output variable */SELECT @HowManyResults=COUNT(*) FROM #SearchedProducts WHERE Rank>0
/* Send back the requested products */SELECT ProductID, Name, Description, Price, ImagePath, ImageALT, ArtistName, Stock, Rank,        CASE SearchCoverQuality            WHEN 1 THEN '5stars.gif'            WHEN 2 THEN '4stars.gif'            WHEN 3 THEN '3stars.gif'            WHEN 4 THEN '2stars.gif'            ELSE '1stars.gif'        END AS CoverQuality,        CASE SearchAlbumQuality            WHEN 1 THEN '5stars.gif'            WHEN 2 THEN '4stars.gif'            WHEN 3 THEN '3stars.gif'            WHEN 4 THEN '2stars.gif'            ELSE '1stars.gif'        END AS AlbumQualityFROM #SearchedProductsWHERE Rank > 0  AND RowNumber BETWEEN (@PageNumber-1) * @ProductsOnPage + 1                     AND @PageNumber * @ProductsOnPageORDER BY Rank DESCi was wondering if i can use full text search on many tables at once?thanks in advance!Tuppers

View 1 Replies View Related

Sql Query For Search Engines

Dec 8, 1999

Hi friends,
Can u let me know how the sql-query, that displays only the first 20 records,and while clicking next button the subsequent records should be diplayed in a web appliaction(search). i want to implement through ADO objects.Because if the search query results in hundreds of records and everything is taken into the memory it will badly affect the performance of the system !right?
Regards
rajesh

View 1 Replies View Related

Keywords Search Query

Feb 6, 2007

Hi,
I'm trying to do a query to do a search by keywords. For example if the user searches for "Hottest restaurants in Atlanta" i want to write a query that searches that exact phrase first in a database field called keywords and if it shows up there then that record should be displayed first.. and then after do a search for EACH one of the words in a number of fields in the database and see if it shows up.

here is what i have so far but it always returns the same thing. any ideas?

$searchArray=explode(" ",$search);
$query = "SELECT ID,name,description from restaurants WHERE keywords = '$search' OR (";

foreach($searchArray as $key){
$query = $query . " (name LIKE '%$key%' OR subType LIKE '%$key%' OR features LIKE '%$key%' OR neighborhood LIKE '%$key%' OR region LIKE '%$key%') OR";

}

$query = substr($query,0,strlen($query)-3);
$query = $query . ") order by keywords";



any ideas?

View 11 Replies View Related

Need Help Writing Search Query

Feb 17, 2005

I am not very familiar with the syntax of MS SQL and I am trying to write a stored procedure which would do a search and return matching records.
This is what I need to achieve:
for instance I create a form with 4 text fields
- First Name
- Last Name
- Employee ID
- Date

I am interested in writing a stored procedure that would run a select query based on the input in the text fields
e.g.
- if the user enters First Name and the Last Name (leaving Employee ID and Date fields blank) query should be something like
select * from Employee where FirstName like @FirstName and LastName like @LastName
- or if the user enters only the Employee ID stored procedure should run a query similar to
select * from Employee where EmployeeID like @EmployeeID

View 9 Replies View Related

Search Query Through 3 Different Fields?

Dec 12, 2014

I have 2 tables.

Clients
Contacts (multiple contacts for one client)

I'm trying to do a search that pulls a contacts where the search matches either the First Name, last Name or the clients name. If it does return clients, I'd like it to also return all the contacts associated with it.

I have two problems:

1. The query is not bringing up a lot of clients. In many cases a letter brings nothing back. Like G and H even though A and B return results.

2. If it finds a client it only returns one contact. I'd like it to return all contacts for the client.

Here's my query:

SELECT addressbook.clientid, clients.clientname, addressbook.addressid, addressbook.fname, addressbook.lname FROM clients, addressbook where clients.clientid = addressbook.addressid
AND (addressbook.fname LIKE
'".strtoupper($_GET['txtsearch'])."%' OR addressbook.lname LIKE
'".strtoupper($_GET['txtsearch'])."%' OR clients.clientname LIKE
'" . strtoupper($_GET['txtsearch'])."%')

View 1 Replies View Related

Search Query Help With Duplicates?

Sep 7, 2006

Hello everyone,

Obviously, I'm new here so I'd like to start by thanking anyone for their help with this very newbie SQL search query question.

I have been tasked with trying to figure out how to get search results from several different columns of two different tables within a database. I have successfully accomplished this, but one column has many many duplicates. I have read on these forums about using the DISTINCT command to eliminate this, but so far have been unsuccessful. Here is the search I'm using...(columns 1, 2, and 3 are from one table and columns 4 and 5 are from another. The results need to be in ascending order (alphabetical) of column1.

select column1, column2, column3, column4, column5 from table1, table2 order by column1;

The result of this is great except that column1 has many duplicates.

I tried entering the search like this...

select distinct column1, column2, column3, column4, column5 from table1, table2 order by column1;

...but that didn't seem to help.

Can someone steer me in the right direction?

Thanks for any and all assistance.

View 8 Replies View Related

I Need A Simple Search Query

Jan 13, 2008

I have a table that has these columns:

LinkID, LinkURL, TimesRedirected

I have a webpage that keeps track of the url's of where the users are coming from. When they redirect to the page, the page will:

If the url of the previous page isn't in the database, add it
Otherwise, add to the TimesRedirected column.

View 6 Replies View Related

Complex Search Query - PLEASE HELP!

Feb 28, 2008

Hi there,

I need a query to join 3 tables. Here is my setup:
TABLEFields
GroupsID, Name
KeywordsID, GroupID, Keyword
SearchID, Keyword

"Groups" and "Keywords" are linked one to many, with each group being assigned multiple keywords. "Search" holds a list of keywords that I want to search for. In particular, I need to find the groups that have ALL of the keywords in "Search" assigned to them (not just at least one). I've tried many different approaches, but cannot find a way to do this with a single query. All my attempts so far also return groups that only have a few of the keywords in "Search" assigned to them, but not ALL.
Can anyone help? I am desperate to find a solution...
Thanks!

Helmut

View 3 Replies View Related

Search Query Between Two Tables

Jul 23, 2005

I'm working on search query for a troubleticket system.There are two tables I want to search, the description in the tickets tableand the corresponding notes in the notes table. The problem is there is aone to many relationship between the tickets (one) and the notes (many)tables.I only need the ticket number of any ticket that finds the search string inthe description or any of the corresponding notes.

View 2 Replies View Related

Search Char In SQL Query

Jul 10, 2006

I have a text field in a table that contains number along with chars.Is there a way i can write a query to show all the fields that containsjust Numbers or Char in a field??TBALE ExampleCOL1 : COL2(nvarchar)---------------------------100 345G01200 123456789300 GQ9220

View 7 Replies View Related

Help With Search Results Query

Jul 20, 2005

I need some help with a query. I have a table with inventory that Ineed to allow customer searches on. Based on their search criteria, apreference level is calculated; the higher the preference level, thehigher on the order on the search results.The hard part is when the results are supposed to be limited to amaximum number of stores and items. Let's say that they only want tosee 3 stores and a max of 5 items per store. What needs to bereturned is the 3 stores with the best Preference and the 5 best itemsat each store.Create Table Inventory( StoreId int, ItemId int, Preference int )

View 1 Replies View Related

How To Create A Search Query

Apr 14, 2008

Code Snippet

CREATE PROCEDURE GetSearchResults
@ParameterValue @varchar(max)
--WITH ENCRYPTION
as
select *
from OPS_Projects
select *
from OPS_Clients

go






I have this stored procedure that has one Parameter ....that parameter value will be a value that can be matched from eithier one of these tables but i am not sure how I need to write query...my logic I would like to read like this

Select * From OPS_Projects Where ThisData = ParameterValue

If this query returns data then, just return that data If not run next query

Select * From OPS_Project Where ThisOtherData = ParameterValue

If this query returns data then, just return that data If not run next query.... and so on....

Is this the best way to do to create a search query???? Any Help I am open for suggestions! Thanks!

View 8 Replies View Related

Criteria Search Query

Jul 30, 2007

I have four criterias in my .aspx page. They are "First Name, Last Name, Title, Year". I have a Book and an Author table. The Author table would contain all the author's information and the Book table contains all the books information such as title, publisher, subject, and so on. So here's what I'm trying to do.

I want to write a transaction statement that will query the four criterias above if the criteria textbox is not black. So for example, when the user click the submit button, all the four criteria fields are filled except Year. That means the query would search the Author and Book tables for "First Name, Last Name, Title" but not "Year" for any potential matches. I also wanted to use "Like" instead of "=" for a wider search.


Actually I'm trying to create a store procedure that will accept those four criterias and search the tables based on those criterias.

Any help is appreciated.

View 11 Replies View Related

SQL Search :: Query To Sum Records?

May 4, 2015

having some issues trying to create a query in excel 2013. I can get the data I want from sql, but I get individual transactions and I want to sum them by plu number. here is my query, I tried using group by but every time I add the field, I get an error that some other field is invalid because it's not contained in an aggregate or group by clause. btw, I didn't name these fields.

SELECT RPT_ITM_D.F254 as [Date], RPT_ITM_D.F01 As [PLU], RPT_ITM_D.F64 As [Qty Sold], RPT_ITM_D.F65 As [SOLD], OBJ_TAB.F17 As [RCode], OBJ_TAB.F29 As [Description], PRICE_TAB.F30 As [EL Price], PRICE_TAB.F31 As [Qty]
FROM STORESQL.dbo.OBJ_TAB OBJ_TAB, STORESQL.dbo.PRICE_TAB PRICE_TAB, STORESQL.dbo.RPT_ITM_D RPT_ITM_D
WHERE OBJ_TAB.F01 = RPT_ITM_D.F01 AND OBJ_TAB.F01 = PRICE_TAB.F01 AND PRICE_TAB.F01 = RPT_ITM_D.F01 AND ((RPT_ITM_D.F254>=? And RPT_ITM_D.F254<=? )AND (OBJ_TAB.F17=25))

View 8 Replies View Related

SQL Query - Search Field For String

Feb 28, 2007

Hi,
I have a SQL server 2005 database with a series of multiple fields. One of the fields has a array of strings seperated by semi-colons like so: Red;Green;Blue
My question is, how can i run a query on all of the fields that have the value of say Green in it. Note that these values vary in different order and numbers.
Thanks

View 2 Replies View Related

How To Handle Complex Sql Search Query

Mar 3, 2006

I am currently faced with developing a search function (ASP.NET 1.1
based user interface) to a database (SQL Server 2000 ), and I am
wondering how best to handle the logistics of it.

The search can take anywhere from one  to 9 parameters. The search would be executed against three related tables.

The main problem, as I see it at this stage, is how to handle
parameters that have not been selected, it's easy enough to do a search
with all 9 parameters, but as soon as there is an unpredictable
variable number of search criteria, I just don't know how best to
handle this in a stored procedure for example.

I would be very grateful for some guidance.

Thanks.

View 1 Replies View Related

Search Query Among All Fields In A Table

Jul 14, 2005

I apologize for the newbie sort of question, but I could not find an answer in an SQL book nor via Google.

I wish to search for a text string in ALL fields of a table. This will be used to provide a simple search box in a web application.

So far, the only method I've found to accomplish this is follows:


SELECT *
FROM Inventory
WHERE SerialNumber LIKE '%searchstring%' OR UserName LIKE '%searchstring%' OR Location LIKE '%searchstring%' ... etc


My goal is to accomplish something like the following. This, of course, does not execute properly since * can only be used following SELECT, but you can get an idea of the target behavior:


SELECT *
FROM Inventory
WHERE * LIKE '%searchstring%'


I'm using MSDE with Visual Basic .Net. Any suggestions on how to accomplish this?

Thanks for all help,
Kieran

View 1 Replies View Related

'Reverse' Search Query For Chat Bot

Oct 8, 2005

I am writing a chat bot for IRC in C#. I am using an Access database (for portability etc) - I have a table called tblResponse, it contains a column called Trigger this contains trigger strings, such as:

% wassup%!%

These contain wildcards etc so that they will match different things spoken in the channel, so the above should match:

hey wassup!!
whoah, a bot ... wassup!!

etc. Because this is comparing general conversations, I am doing sort of a reverse search, in that it is not what I am passing in that I am using as the search string, it is what is in the column of the database that serves as the search string. I don't want to have to store the chat text in a temp table and loop through the Response table, calling sql queries for every entry - but all the queries I have tried do not work as intended.

I have tried switching the select query variables like this (this is called from c#, so for here i have just inserted a test value):

SELECT *
FROM tblResponse
WHERE Trigger like 'hey wassup!!!';

This returns nothing, so does:

SELECT *
FROM tblResponse
WHERE 'hey wassup!!!' like Trigger;

Is there anyway I can perform such a search within a sql query that can be processed by MS Access? To recap (in case I have done a poor job explaining this)... I need to use the database entries as the search criteria, if that criteria matches the incoming text string (using the wildcards in the database entries), then return that row - the exact opposite of a convensional 'search' query.


Thanks in advance!!!!

- invid

View 7 Replies View Related

Search Query With Optional Parameters

Jun 12, 2006

I need to create a stored procedure that will search some tables.

The stored procedure will be passed some parameters that may or may not have a value.

I have googled the best way to do this.
I found this post as an example: Optional Search Parameters

and also found this example : Optional Parameters in T-sQL

I am trying to figure out the best way to do this.

In the past I would build a dynamic query like the following.


SQL Code:






Original
- SQL Code




CREATE PROCEDURE [dbo].[Search_Results]

@SUBCITY VarChar(100) = 'Any'

AS

------------------------------------------------------------------------------------------------------
Declare @SUBCITYString Varchar(200)
If @SUBCITY <> 'Any'
Begin
Set @SUBCITYString = ' AND (Table1.SUBCITY LIKE ''' + @SUBCITY + '%'') '
End
Else
Begin
Set @SUBCITYString = ''
End
-----------------------------------------------------------------------------------------------------

Declare @SQLString As Varchar(500)
Set @SQLString = 'SELECT*

FROMTable1

WHERE Table1.ID IS NOT NULL
' + @SUBCITYString + '

ORDER BY Column ASC'

Execute (@SQLString)

GO






CREATE PROCEDURE [dbo].[Search_Results]  @SUBCITY VarChar(100) = 'Any' AS ------------------------------------------------------------------------------------------------------DECLARE @SUBCITYString Varchar(200)IF @SUBCITY <> 'Any' BEGIN  SET @SUBCITYString = ' AND (Table1.SUBCITY  LIKE ''' + @SUBCITY + '%'') 'ENDELSE BEGIN SET @SUBCITYString = '' END----------------------------------------------------------------------------------------------------- DECLARE @SQLString AS Varchar(500)SET @SQLString = '  SELECT    *                            FROM  Table1               WHERE  Table1.ID IS NOT NULL                ' + @SUBCITYString +  '            ORDER BY Column ASC' Execute (@SQLString) GO


However this is really cumbersome to create and is not fun debugging!

Does one of these ways have an advantage over the other? Or is there another way to do this?

Thank you!

View 2 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved