I have problems writing this query. I do not know that I really should use counts because it Gives real count and I want to return those people who made a review. Anyway this is my query that I am trying to write.
Search for users who have not reviewed any business.
The tables I am using
Reviews; + ------------- + --------- + ------ + ----- + --------- + - - ---- + | Field | Type | Faucet Key | Default | Extra | + ------------- + --------- + ------ + ----- + --------- + - - ---- + | Business_id | Int (11) | No | PRI | Faucet | | User_id | Int (11) | No | PRI | Faucet | | Review_id | Int (11) | No | PRI | Faucet | | Review_date | Date | Yes. | Faucet | | Star_rating | Int (1) | Yes. | 1 | Business + -------------- + -------------- + ------ + ----- + ----- ---- + ------- + | Field | Type | Faucet Key | Default | Extra | + -------------- + -------------- + ------ + ----- + ------ --- + ------- + | Business_id | Int (11) | No | PRI | Faucet | | Name | Varchar (50) | Yes. | Faucet | | City | Varchar (40) | Yes. | Faucet | | State | Varchar (20) | Yes. | Faucet | | Full_address | Varchar (120) | Yes. | Faucet | Users; + ------------ + ------------- + ------ + ----- + --------- + ------- + | Field | Type | Faucet Key | Default | Extra | + ------------ + ------------- + ------ + ----- + --------- + ------- + | User_id | Int (11) | No | PRI | Faucet | | Name | Varchar (50) | Yes. | Faucet | | User_since | Date | Yes. | NULL
Even so far away from me
SELECT reviews.user_id Join the review on businesses (reviews.business_id = businesses.business_id) Review by Group .user_id ASC Hosting COUNT (*) & gt; 0;
This returns 0 results and I do not think it's right because a user can and can not write reviews. But I do not know what I can do. Thanks
Edit: I have made the last inquiry, but now I am trying to fulfill it!
Find users reviewing each business
What we are saying in the table of users joining the review table - I get all the users and if they do not leave any reviews, then leave those columns only as zeros, where the clause In, we are only selecting those results, where the review column is faucet, so that users are selected who have not left a review.
Select User R.user_id = u.user_id where r.review_id is empty
No comments:
Post a Comment