The Geek Forum

  • May 21, 2024, 09:01:26 AM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Due to the prolific nature of these forums, poster aggression is advised.

*

Recent Forum Posts

Shout Box

Members
Stats
  • Total Posts: 129651
  • Total Topics: 7198
  • Online Today: 154
  • Online Ever: 1013
  • (January 12, 2023, 01:18:11 AM)
Pages: 1 2 [3]

Author Topic: computer programming  (Read 8570 times)

ivan

  • Forum Moderator
  • Hacker
  • *
  • Coolio Points: +499/-50
  • Offline Offline
  • Posts: 4929
  • Not a Mod, nor a Rocker. A Mocker.
    • View Profile
Re: computer programming
« Reply #50 on: March 22, 2007, 03:58:08 PM »

So did you find a boolean statement that does the trick?

I would've probably settled for a UNION juke.


select distinct OrderID from Order_Items where OrderItemType = Kitty and @HasKitty = 1
union
select distinct OrderID from Order_Items where OrderItemType = Doggy and @HasDoggy = 1
union
select distinct OrderID from Order_Items where OrderItemType = Puppy and @HasPuppy = 1
Logged
"I TYPE 120 WORDS PER MINUTE, BUT IT'S IN MY OWN LANGUAGE!"  -Detta

xolik: WHERE IS OBAMA'S GIFT CERTIFICATE?
Demosthenes: Is that from the gifters movement?


Detta: Crappy old shorts and a tank top.  This is how I dress for work. Because my job is to get puked on.
Demosthenes: So is mine.  I work in IT.


bananaskittles: The world is 4chan and God is a troll.

Pyrenus

  • Jail Bait
  • *
  • Coolio Points: +30/-4
  • Offline Offline
  • Posts: 115
    • View Profile
Re: computer programming
« Reply #51 on: March 22, 2007, 04:14:33 PM »

Yeah, I finally got it working:

select orders.* from orders
LEFT OUTER JOIN order_items P ON orderID = orderID AND type = PUPPY
LEFT OUTER JOIN order_items D ON orderID = OrderID AND type = Doggy
LEFT OUTER JOIN order_items K ON orderID = orderID AND type = Kitty
WHERE ISNULL(P.ID, 0) =
CASE
WHEN @HasKitty = 1 THEN ISNULL(P.ID, 1)
ELSE -1
END
AND ISNULL(D.ID, 0) =
CASE
WHEN @HasDoggy = 1 THEN ISNULL(D.ID, 1)
ELSE -1
END
AND ISNULL(K.ID, 0) =
CASE
WHEN @HasKitty = 1 THEN ISNULL(K.ID, 1)
ELSE -1
END



Logged

Pyrenus

  • Jail Bait
  • *
  • Coolio Points: +30/-4
  • Offline Offline
  • Posts: 115
    • View Profile
Re: computer programming
« Reply #52 on: March 22, 2007, 04:30:08 PM »

Thanks, I'll try it.
Logged
Pages: 1 2 [3]