How to Restrict Database for One User in SQL Server 2008 R2?

Help with basic SQL SELECT Statement?

  • I was hoping to get some assistance with the query below. I was able to create the individual SELECT statements against the Pubs database in SQL Server 2008 R2, but I am not sure how to join them as one select query so the results come up in one table and not three individual tables: SELECT * FROM stores WHERE state= 'CA' SELECT * FROM sales WHERE payterms='Net 30' SELECT * FROM sales WHERE qty >=’20’ *Any help would be greatly appreciated.

  • Answer:

    Don't know if this is exactly right but this is what comes to mind as a start: SELECT state, payterms, qty FROM stores, sales WHERE (state='CA' OR payterms='Net 30' OR qty>='20');

Rob at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

Don't know if this is exactly right but this is what comes to mind as a start: SELECT state, payterms, qty FROM stores, sales WHERE (state='CA' OR payterms='Net 30' OR qty>='20');

Toad

It would help if you had listed the relevant schema, but if you can't do it with a join, perhaps subqueries would work...something like SELECT <whatever> FROM <whatever source tables needed> WHERE sales.store_ID IN (SELECT store_ID FROM stores WHERE state = 'CA') AND (sales.payterms = 'Net 30' AND sales.qty >= 20)

TheMadProfessor

It would help if you had listed the relevant schema, but if you can't do it with a join, perhaps subqueries would work...something like SELECT <whatever> FROM <whatever source tables needed> WHERE sales.store_ID IN (SELECT store_ID FROM stores WHERE state = 'CA') AND (sales.payterms = 'Net 30' AND sales.qty >= 20)

TheMadProfessor

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.