user3706416
user3706416

Reputation: 1

How to not include a set of results in result without using a where clause in SQL

I am currently use 4 tables to get the extract of data, i them remove some of the rows in excel. Is there a way where i can add a condition in select statement without manipulating the where clause. Ex:

Results
Supplier    Product & extra
Sky         Broadband & mobile minutes
Sky         fiber broadband & internet security
TalkTalk    Simply broadband & mobile minutes
EE          Unlimited broadband & mobile minutes
EE          fiber broadband & international minutes

Tbl1 provides suppliers info, tbl2 provides product info and tbl3 provides extra info. I need to remove EE with mobile minutes info from results while keeping the rest of EE. I am not sure how to do this. Any help would be greatly appreciated.

Upvotes: 0

Views: 57

Answers (2)

Andy Nichols
Andy Nichols

Reputation: 3002

Based on your comment

my where clauses is something like this "WHERE Extra IN (30, 44, 106, 107, 29, 68) AND serviceProvider IN (1, 2, 3, 10, 143, 149, 154, 159, 165, 167, 166, 168, 176, 177)

if EE had the id of 143 and mobile minutes had the id of 106 you could just add a NOT to your existing WHERE clause. Your WHERE clause would then become:

WHERE Extra IN (30, 44, 106, 107, 29, 68)
AND serviceProvider IN (1, 2, 3, 10, 143, 149, 154, 159, 165, 167, 166, 168, 176, 177)
AND NOT (Extra = 106 AND serviceProvider = 143)

obviously changing it to use the correct id for extra and service provider.

Upvotes: 1

Lidia D.
Lidia D.

Reputation: 21

You cannot limit your number of rows in the select, but if you do not want to use WHERE, you can add your conditions in your JOIN (i.e. FROM T1 JOIN T2 ON T1.col = T2.col and T2.my_col = 'smth')

Lidia D.

Upvotes: 0

Related Questions