Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

simple querey help 1

Status
Not open for further replies.

techninut

Technical User
Nov 28, 2001
92
US
Well simple for one of you guys/gals out there maybe

anyways, I have written a querey in order to retrieve a list of information from some tables. Now what I would like to do is run another querey to run a list that is not in the list I just ran a querey on. Hope I have not confused anyone just yet.
Here is what I have thus far and I know it is wrong but it explains what I am trying to do.

Code:
SELECT x_DATABASE_NAME FROM x_DATABASES
WHERE x_DATABASE_NAME
NOT IN

(SELECT     x_databases.x_database_name, remote_agent.remote_agent_name
FROM         x_databases INNER JOIN
                      xa_remote_agents ON x_databases.database_id = xa_remote_agents.database_id INNER JOIN
                      remote_agent ON xa_remote_agents.remote_agent_id = remote_agent.remote_agent_id
)


the error I am getting is this:

Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.

I hope this helps a bit. Sorry if this seems remedial but I am not quite an expert.

Any help would be appreciated.


T
 
Just get rid of the second column in your subquery:

Code:
SELECT x_DATABASE_NAME
FROM x_DATABASES
WHERE x_DATABASE_NAME NOT IN (
    SELECT x_databases.x_database_name[COLOR=red][s], remote_agent.remote_agent_name[/s][/color]
    FROM x_databases
      INNER JOIN xa_remote_agents ON x_databases.database_id = xa_remote_agents.database_id
      INNER JOIN remote_agent ON a_remote_agents.remote_agent_id = remote_agent.remote_agent_id
  )

--James
 
Perfect !!! Thank you so much. Star for you !!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top