SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Addict mr.pita's Avatar
    Join Date
    Aug 2005
    Location
    USA
    Posts
    303
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    View not working, select working

    When I run this, I get an empty set of results back (no errors though):

    Code:
    drop view if exists wrentals;
    
    create view wrentals as
    select c.CustName from customer as c
    join transactions as t on t.MemberID=c.MemberID
    group by c.CustName;
    But if I run just the select part from above, it works fine, and I actually get the results I'm looking for:

    Code:
      
    select c.CustName from customer as c
    join transactions as t on t.MemberID=c.MemberID
    group by c.CustName;
    What can cause this? Using MySQL 5.1

  2. #2
    SitePoint Wizard PHPycho's Avatar
    Join Date
    Dec 2005
    Posts
    1,201
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    select c.CustName from customer as c
    join transactions as t on t.MemberID=c.MemberID
    group by c.CustName;
    is this query giving some results?

    why don't you use specific join (join simply means INNER JOIN)?
    Before posting please do format your code with proper wrapping.
    formatted mysql code:
    Code MySQL:
    SELECT 
    	c.CustName 
    FROM 
    	customer AS c
    	INNER JOIN transactions AS t ON t.MemberID = c.MemberID
    GROUP BY 
    	c.CustName;

  3. #3
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,510
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Maybe I misunderstand your question, but the creation of a view doesn't return any result set, or does it?

  4. #4
    SitePoint Addict SirAdrian's Avatar
    Join Date
    Jul 2005
    Location
    Kelowna, BC
    Posts
    289
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by guido2004 View Post
    Maybe I misunderstand your question, but the creation of a view doesn't return any result set, or does it?
    Doesn't.
    Adrian Schneider - Web Developer

  5. #5
    SitePoint Addict mr.pita's Avatar
    Join Date
    Aug 2005
    Location
    USA
    Posts
    303
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure what I did differently but all of a sudden it works.
    Thanks everyone!

  6. #6
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    that's called the "aoas" effect

    post a question on a forum, and all of a sudden it works again

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •