Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6898949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:21:37+00:00 2026-05-27T07:21:37+00:00

I have the following little bit of MySQL code CREATE VIEW UserResults AS SELECT

  • 0

I have the following little bit of MySQL code

CREATE VIEW UserResults AS 
   SELECT E.No, E. Description
      , Count(R.RID WHERE $Username= R.Owner)
      , Count(R.RID WHERE $Username= R.Owner AND Status==’Active’ ) 
   FROM ETable AS E, RTABLE as R
   ORDER BY E.No)

but MySQL is returning a syntax error that I can’t seem to find. Also when I have created this view, how can I make it viewable?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:21:37+00:00Added an answer on May 27, 2026 at 7:21 am
    • You have an extra ending parenthesis, which should be removed
    • Views should not have ORDER BY.
    • The WHERE clause should not be in the middle of the SELECT, you will need to use a CASE.
    • You are returning a Cartesian product instead of joining your tables together, this may provide more results than you want/expect.

    The R.RID in the THEN block of the CASE statements may need to be a 1, not entirely sure what you hoped to get from those COUNT statements you originally had.

    I tried to figure out what you were trying to do, and I think this is it:

    CREATE VIEW UserResults AS
       SELECT E.No, E.Description
          , SUM(CASE 
                   WHEN $Username = R.Owner THEN R.RID
                   ELSE 0
                END) AS SumOfOwner
          , SUM(CASE
                   WHEN $Username = R.Owner AND Status = 'Active' THEN R.RID
                   ELSE 0
                END) AS SumOfOwnerAndActive
       FROM ETable AS E
       INNER JOIN RTABLE as R ON E.No = R.ENo
       GROUP BY E.No, E.Description
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is a little bit complex. I have the following code: $(document).ready(function() {
I am little bit confused about following problem & their solutions: i have 2
I'm a little bit confused with the use of @. In the following code
I have a little bit complex MySQL query for me and i can't figure
Ok. I have this little bit of code that is supposed to use text
I have a little bit of code and it doesn't seem to be working
I have a little bit of problem here: I have the following js functions:
I am having a little bit trouble with the following. I have multiple form
I'm having a little difficulty understanding alias_method / alias_method_chain . I have the following
Following the good jQuery Plugins/Authoring instructions I have a little question (function($){ // Default

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.