2 Replies - 588 Views - Last Post: 07 March 2012 - 08:01 PM

#1 asdbabil  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 241
  • Joined: 26-October 08

Nested Join doesnt execute

Posted 05 March 2012 - 03:52 PM

Im trying to run the following code but it doesnt execute. It works perfectly if i remove the 4th table but not when i have all 4 tables.

please help

SELECT * FROM(
SELECT * FROM(
SELECT * FROM vtiger_seactivityrel as T1 
JOIN vtiger_activity_reminder as T2 ON T1.activityid = T2.activity_id WHERE 1) as T12
JOIN vtiger_crmentity as T3 ON T12.activity_id = T3.crmid WHERE 1) as T123 
JOIN vtiger_leadaddress as T4 ON T123.activity_id = T4.leadaddressid WHERE 1



Is This A Good Question/Topic? 0
  • +

Replies To: Nested Join doesnt execute

#2 Atli  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3040
  • View blog
  • Posts: 4,555
  • Joined: 08-June 10

Re: Nested Join doesnt execute

Posted 05 March 2012 - 04:59 PM

Can you explain to us what this query is supposed to be doing?
I'm having a hard time figuring that out. Your table names don't make much senes. For instance, what is "seactivityrel" supposed to be?

Why do you nest the joins like that? Have you tried just doing it the normal way?
That is, like this: (Or some version of this. As I don't know what it is you are doing, I can only really guess at the order of these joins.)
SELECT * FROM tiger_seactivityrel as T1 
JOIN vtiger_activity_reminder as T2 
	ON T1.activityid = T2.activity_id
JOIN vtiger_crmentity as T3 
	ON T2.activity_id = T3.crmid
JOIN vtiger_leadaddress as T4 
	ON T2.activity_id = T4.leadaddressid



And why do you add a WHERE 1 after each join? It's implied that a row is returned unless the WHERE clause evaluates to FALSE, so this is kind of pointless.
Was This Post Helpful? 1
  • +
  • -

#3 asdbabil  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 241
  • Joined: 26-October 08

Re: Nested Join doesnt execute

Posted 07 March 2012 - 08:01 PM

The query suppose to join 4 tables. And yes I know some of the tables names dont make sense but I have no control over the names.....and the reason I did it that way is because I followed somebody's way. Your way fix the problem ..thank you :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1