Useless Query

I just ran across this in an SP and I thought I’d share it with you guys…

Select RegionName from Regions
where RegionName IN (‘SC’, ‘MW’, ‘NE’, ‘NC’, ‘NW’)

For some reason, I just love the uselessness of this whole thing.

2 thoughts on “Useless Query”

  1. There is a sense in that. Imagine the following table contents:

    insert into Regions (RegionName)
    select ‘SC’ union
    select ‘NW’ union
    select ‘NA’

    Now try your query. As you can see, output will be limited by both IN() list and table data. But yes, I doubt that authors of such crap ever think about this weird case… 🙂

Comments are closed.