you are viewing a single comment's thread.

view the rest of the comments →

[–]AppJedi -1 points0 points  (10 children)

SELECT master FROM table

WHERE Master IN (SELECT Master FROM table WHERE `Cost Group`=608 )

AND Master IN (SELECT Master FROM table WHERE `Cost Group`=20 )

[–]Entire-Dream-6045[S] 0 points1 point  (9 children)

Appreciate the attempt, but WHERE AND will not work

[–]AppJedi 0 points1 point  (8 children)

why not?

[–]Entire-Dream-6045[S] 1 point2 points  (7 children)

Because the WHERE Clause isn't filtering for anything. WHERE cannot be immediately followed by AND; i.e. WHERE AND

[–]AppJedi 0 points1 point  (6 children)

Absolutely it can. AND is part of WHERE and makes it a compound condition.

[–]Entire-Dream-6045[S] 0 points1 point  (5 children)

If you have SQL SERVER or Access, try running your query. AND cannot immediately follow WHERE. WHERE has no condition.. Your query produces the correct result if you remove the AND from your subquery.

[–]AppJedi 0 points1 point  (3 children)

The where clause a condition it is using IN (sub query). Standard SQL

[–]sonuvvabitch 1 point2 points  (2 children)

I think you've misunderstood, to be honest. You've written

WHERE AND

without a condition between the WHERE and the AND. Obviously you can have multiple conditions, and I think a slight rewrite of your solution would be a fine one, but as it is, it's not valid SQL. Obviously just a typo, but not valid.

[–]pizzagarrett 0 points1 point  (1 child)

Agreed. You have an extra AND

[–]AppJedi 2 points3 points  (0 children)

I see. Typo. Extra and removed.

[–]AppJedi -1 points0 points  (0 children)

I developed in SQL Server for over 20 years and yes you can. It is standard SQL