Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Interesting Where clause I have not seen before

Author  Topic 

youruseridistoxic
Yak Posting Veteran

65 Posts

Posted - 2010-02-16 : 11:46:42
Good morning all,

A colleague of mine brought me a sample TSQL statement that included the following 'Where' clause;

Select * from dbo.Table1
WHERE (Details.AccountNo = '<25/>') AND (Address.Type = '<26/>')


I am unfamiliar with how to use something like '<25/>' as a condition on a result set, and was unable to find anything in a search.

Is there a simple answer to this one?

Thanks so much to all who reply!

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-02-16 : 11:48:22
It is just stored like this in the database, there is no magic I believe.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

youruseridistoxic
Yak Posting Veteran

65 Posts

Posted - 2010-02-16 : 11:53:22
quote:
Originally posted by webfred

It is just stored like this in the database, there is no magic I believe.


No, you're never too old to Yak'n'Roll if you're too young to die.



That's what I originally thought too - except running the query with this condition returns 0 results. Omit the condition, and 1000+ records are returned.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-02-16 : 11:59:48
quote:
Originally posted by youruseridistoxic

quote:
Originally posted by webfred

It is just stored like this in the database, there is no magic I believe.


No, you're never too old to Yak'n'Roll if you're too young to die.



That's what I originally thought too - except running the query with this condition returns 0 results. Omit the condition, and 1000+ records are returned.


That means your db doesnt have any rows which have AccountNo values like '<25/>' or '<26/>'

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-02-16 : 12:19:28
Has the '<25/>' value come from a form on a web page?

If so I reckon its accidentally got the HTML tags around it, for some reason.

Does

Select COUNT(*)
from dbo.Table1
WHERE (Details.AccountNo = '25') AND (Address.Type = '26')

give you a "reasonable" number of records? If so maybe that is the query that the system was trying to generate?
Go to Top of Page

youruseridistoxic
Yak Posting Veteran

65 Posts

Posted - 2010-02-16 : 13:05:54
Clearly, further research is required before I can say with confidence the syntax is correct in its current form (and therefore specifically looking for the values at hand), or the query is incorrect and these conditions should be formatted differently.

Thanks to all who've responded. This obviously isn't some little-known TSQL construct I had yet to discover :)

More info to follow....
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2010-02-16 : 13:08:49
"This obviously isn't some little-known TSQL construct I had yet to discover :)"

Well if it is look at the long queue of all of us right behind you
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-02-17 : 03:50:36
quote:
Originally posted by youruseridistoxic

Good morning all,

A colleague of mine brought me a sample TSQL statement that included the following 'Where' clause;

Select * from dbo.Table1
WHERE (Details.AccountNo = '<25/>') AND (Address.Type = '<26/>')


I am unfamiliar with how to use something like '<25/>' as a condition on a result set, and was unable to find anything in a search.

Is there a simple answer to this one?

Thanks so much to all who reply!


Seems you have posted partial code
There is no information about the tables Details and Address

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-02-17 : 08:26:33
what's the data type of Details.AccountNo?
Go to Top of Page
   

- Advertisement -