Results 1 to 2 of 2

Thread: SQL query help

  1. #1
    redhat66 is offline Member
    Join Date
    May 2009
    Posts
    11

    Default SQL query help

    Greeting to the Community and prop's to the SugarCRM developers.

    I hope I'm in the correct forum.

    I am trying to build a query that will pull "name" of "account_type" from the `accounts` table and match it to the "description" field from `notes`. I can achieve the results I need with separate query's but need to condense into one query.

    //Potential AVD

    SELECT a.`name`, n.`description`, n.`date_modified`
    FROM accounts a
    JOIN notes n
    ON a.id = n.parent_id
    JOIN users u
    ON u.id = a.assigned_user_id
    WHERE a.`account_type`="Potential AVD"


    //AVD

    SELECT a.`name`, n.`description`, n.`date_modified`
    FROM accounts a
    JOIN notes n
    ON a.id = n.parent_id
    JOIN users u
    ON u.id = a.assigned_user_id
    WHERE a.`account_type`="AVD"


    //A&E

    SELECT a.`name`, n.`description`, n.`date_modified`
    FROM accounts a
    JOIN notes n
    ON a.id = n.parent_id
    JOIN users u
    ON u.id = a.assigned_user_id
    WHERE a.`account_type`="A&E"


    //Platinum Dealer

    SELECT a.`name`, n.`description`, n.`date_modified`
    FROM accounts a
    JOIN notes n
    ON a.id = n.parent_id
    JOIN users u
    ON u.id = a.assigned_user_id
    WHERE a.`account_type`="Platinum Dealer"


    //National Account

    SELECT a.`name`, n.`description`, n.`date_modified`
    FROM accounts a
    JOIN notes n
    ON a.id = n.parent_id
    JOIN users u
    ON u.id = a.assigned_user_id
    WHERE a.`account_type`="National Account"


    //End User Account

    SELECT a.`name`, n.`description`, n.`date_modified`
    FROM accounts a
    JOIN notes n
    ON a.id = n.parent_id
    JOIN users u
    ON u.id = a.assigned_user_id
    WHERE a.`account_type`="End User Account"


    //Opportunitie Notes:

    SELECT o.`name`, n.`description`, n.`date_modified`
    FROM opportunities o
    JOIN notes n
    ON o.id = n.parent_id
    JOIN users u
    ON u.id = o.assigned_user_id

  2. #2
    redhat66 is offline Member
    Join Date
    May 2009
    Posts
    11

    Default Re: SQL query help

    I received an answer to this question in another post.

    Please reference
    http://www.sugarcrm.com/forums/showthread.php?t=55128

    Thank you to all who viewed.

    redhat66

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 7
    Last Post: 2011-08-18, 01:48 PM
  2. Query Failed: ::MySQL error 1065: Query was empty
    By darcy.rippon in forum Developer Help
    Replies: 3
    Last Post: 2008-10-10, 07:24 AM
  3. Replies: 3
    Last Post: 2008-09-30, 08:43 PM
  4. Replies: 2
    Last Post: 2006-10-20, 12:00 AM
  5. Query Failed: ::MySQL error 1065: Query was empty
    By suruchi in forum Developer Help
    Replies: 1
    Last Post: 2006-01-21, 03:16 PM

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
  •