Jump to content

equaling two subquery?

- - - - -

  • Please log in to reply
2 replies to this topic

#1
Hamed

Hamed

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 276 posts
Is it possible that I use this

SELECT *
FROM orders
WHERE (SELECT MAX(day)) = (SELECT MAX(day_of_order)) FROM orders



#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
  • Programming Language:Java, JavaScript, PL/SQL
  • Learning:Java
Not like you wrote it, with 2 separate SELECTS you can:
WHERE (SELECT MAX(day) FROM orders) = (SELECT MAX(day_of_order) FROM orders)

Note that this will select every row from the orders table if it is true.

#3
LuthfiHakim

LuthfiHakim

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 763 posts
Although popular db nowadays already support it, but first you must check your database to see if it's supporting subquery. And if it supports subquery, I believe you must rephrase your query, just like win DC mentioned. Maybe you could explain what are you trying to achieve using subquery?




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users