Home » SQL & PL/SQL » SQL & PL/SQL » question for "where x in" SQL
question for "where x in" SQL [message #299354] Mon, 11 February 2008 11:12 Go to next message
gevaas
Messages: 3
Registered: February 2008
Junior Member
hi
i have a general question in sql. it doesn't really matter which database (oracle or whatever) the next sql statments is written on. is the next statment legal in sql:

Select *
from parts
where parts.id in ( Select * from .....)

the question refers to to "select *" inside the "in" statment. is it legal or do i need to specificly use "select pid from..."
thanks
Re: question for "where x in" SQL [message #299356 is a reply to message #299354] Mon, 11 February 2008 11:16 Go to previous messageGo to next message
pablolee
Messages: 2834
Registered: May 2007
Location: Scotland
Senior Member
It might be valid, if the table in the subquery had only 1 column, otherwise you would have tyo specify the required column.
Re: question for "where x in" SQL [message #299357 is a reply to message #299356] Mon, 11 February 2008 11:18 Go to previous messageGo to next message
gevaas
Messages: 3
Registered: February 2008
Junior Member
thanks for your quick answer.
the table doesn't have only one column so i guess that it's not valid!
thanks Smile
Re: question for "where x in" SQL [message #299359 is a reply to message #299357] Mon, 11 February 2008 12:03 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Even if it is valid, never do that in a real program or you will have problems if someone thinks it is a good idea to add a column.

Always name the columns in your statements.

Regards
Michel
Re: question for "where x in" SQL [message #299380 is a reply to message #299359] Mon, 11 February 2008 15:14 Go to previous message
gevaas
Messages: 3
Registered: February 2008
Junior Member
thank you michel for your comment
i really appreciate it
asaf
Previous Topic: how to view the code written in a procedure
Next Topic: Unknown Issue with Oracle procedure
Goto Forum:
  


Current Time: Sat Dec 03 11:44:13 CST 2016

Total time taken to generate the page: 0.12330 seconds