dbTalk Databases Forums  

join with subquery execution error

comp.databases.mysql comp.databases.mysql


Discuss join with subquery execution error in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
amvis
 
Posts: n/a

Default join with subquery execution error - 12-14-2011 , 02:27 AM






This is i tried the query join with sub-query..i think it have some syntax error...?

select count(*)
from (
SELECT transactions.loyalty_id FROM transactions JOIN loyalties ON (transactions.loyalty_id = loyalties.id) GROUP BY transactions.loyalty_id HAVING COUNT(*)>1 where loyalties.created_at > '2011-11-02'
) as t

Thank you
vishnu

Reply With Quote
  #2  
Old   
amvis
 
Posts: n/a

Default Re: join with subquery execution error - 12-14-2011 , 02:50 AM






yes i got it. That was the problem with where clause position



select count(*)
from (
SELECT transactions.loyalty_id FROM transactions JOIN loyalties ON (transactions.loyalty_id = loyalties.id) where loyalties.created_at > '2011-11-02' GROUP BY transactions.loyalty_id HAVING COUNT(*)>1
) as t

Reply With Quote
  #3  
Old   
Álvaro G. Vicario
 
Posts: n/a

Default Re: join with subquery execution error - 12-14-2011 , 03:24 AM



El 14/12/2011 9:27, amvis escribió/wrote:
Quote:
This is i tried the query join with sub-query..i think it have some syntax error...?

select count(*)
from (
SELECT transactions.loyalty_id FROM transactions JOIN loyalties ON (transactions.loyalty_id = loyalties.id) GROUP BY transactions.loyalty_id HAVING COUNT(*)>1 where loyalties.created_at> '2011-11-02'
) as t
When a query has a syntax error, MySQL will tell you so. Run the query
and read the error message if any.



--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.