Jump to content

Combine two MySQL queries


rma.eugene

Recommended Posts

Hey All,

 

Any way to combine this ugliness?

 

   $query2 = ' Select ' .
            'a.BodyLength,' .
            'a.ContentType,' .
            'a.CreatedById,' .
            'a.Name,' .
            'a.ParentId,' .
            'a.SystemModstamp' .
            " from Attachment a WHERE ParentId = " . $where;
    $query3 = 'Select' .
            'n.CreatedById,' .
            'n.CreatedDate,' .
            'n.OwnerId,' . 'n.ParentId,' .
            'n.SystemModstamp,' .
            'n.Title' .
            "from Note n WHERE ParentId = " . $where;

 

thanks in advance!

Link to comment
https://forums.phpfreaks.com/topic/203468-combine-two-mysql-queries/
Share on other sites

   $query2 = ' Select ' .
            'a.BodyLength,' .
            'a.ContentType,' .
            'a.CreatedById,' .
            'a.Name,' .
            'a.ParentId,' .
            'a.SystemModstamp,' .
            'n.CreatedById,' .
            'n.CreatedDate,' .
            'n.OwnerId,' . 'n.ParentId,' .
            'n.SystemModstamp,' .
            'n.Title' .
            " from Attachment a JOIN Note n ON n.ParentId = a.ParentId WHERE ParentId = " . $where;

thanks! thats what I was looking to do. unfortunately...

 

SoapFault exception: [sf:MALFORMED_QUERY] MALFORMED_QUERY: n.SystemModstamp,n.Title from Attachment a JOIN Note n ON n.ParentId = a.ParentId ^ ERROR at Row:1:Column:176 unexpected token: JOIN in D:\websites....

 

cant do 'join' with soap client??

No clue. Never used the SOAP client.

 

You can try this:

   $query2 = ' Select ' .
            'a.BodyLength,' .
            'a.ContentType,' .
            'a.CreatedById,' .
            'a.Name,' .
            'a.ParentId,' .
            'a.SystemModstamp,' .
            'n.CreatedById,' .
            'n.CreatedDate,' .
            'n.OwnerId,' . 'n.ParentId,' .
            'n.SystemModstamp,' .
            'n.Title' .
            " from Attachment a, Note n WHERE n.ParentId = a.ParentId AND a.ParentId = " . $where;

Sadly...

 

SoapFault exception: [sf:MALFORMED_QUERY] MALFORMED_QUERY: Attachment a, Note n WHERE n.ParentId = a.ParentId AND a.ParentId = 'a045000000CTXumAAH' ^ ERROR at Row:1:Column:203 unexpected token: 'a.ParentId' in D:\websites...

 

Seems like that should have worked. Guess I'll run two queries. shouldn't be too big an issue?

 

thanks

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.