Subquery Error

I ran across an issue with a subquery where I included a non-existent column.

select * from [Table1] where [ColumnA] in (

select [ColumnA] from [Table2] where [ColumnB] = true)

In this case, ColumnB didn’t belong to Table2. Running the subquery (select [ColumnA] from [Table2] where [ColumnB] = true) by itself would raise an error, since ColumnB isn’t in the table. But running the entire query returns an empty result set with no error raised.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: