You are here: Re: Tough SQL problem, need expert advice!!! « MsSQL Server « IT news, forums, messages
Re: Tough SQL problem, need expert advice!!!

Posted by Erland Sommarskog on 06/09/06 07:14

John (johnxhc@yahoo.com) writes:
> Unfortunately I did not write the parser, it is a generic component,
> passing me the following information
> 1) Field
> 2) Operation
> 3) Value
> I could replace all of the value above
> but the parser does not passing me the logic operator, even if it
> does, it is going to be very hard to for me to do a union because I
> could get very complicated logical operation and I could end up query
> the same table multiple time for different fields. Such as
> (Lastname='johnson' or firstname='smith') and (city='Los Angeles')
> or (productid in (234,23434,33) and (Lastname='Smith' or
> firstname='tom'))

Sounds like it's time to reconsider the solution from bottom up. Or accept
that you will never get a solution that performs well.

Not that I know that the UNION thing is going to run with lightning speed,
but the less degree of freedom you have, the poorer are you odds.

In any case, I feel that I cannot give much further advice, because there
is too much I don't know.

> also for "and" operation, I will need to do a intersection instead
> of union. I do not believe SQLServer provide this function on
> transaction sql.

INTERSECT is indeed a new operator, akin to UNION that was added in SQL
2005.

Although AND conditions are probably better implemented with regular AND
operators. They are far less devilish than the OR.



--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация