AnsweredAssumed Answered

Why is my query not using my SELECT?

Question asked by Kenneth Brill on Dec 2, 2018
Latest reply on Dec 3, 2018 by André Lopes

I have a select in my code that is only 3 fields but the query selects them all, what am I missing?

Code

$query = new SugarQuery();     
$query->from(BeanFactory::newBean('Leads'), array('team_security' => false));     
$query->select(array('id', 'date_modified', 'secondary_lead_status_c'));     
$query->where()->queryOr()
->equals('secondary_lead_status_c', 'HOT')          
->equals('secondary_lead_status_c', 'Follow up');     
$leadList = $query->execute();

Query Created

SELECT leads.id, leads.date_entered, leads.date_modified, leads.modified_user_id, 
leads.created_by, leads.description, leads.deleted, leads.salutation, leads.first_name,
leads.last_name, leads.title, leads.facebook, leads.twitter, leads.googleplus,
leads.department, leads.do_not_call, leads.phone_home, leads.phone_mobile,
leads.phone_work, leads.phone_other, leads.phone_fax, leads.primary_address_street,
leads.primary_address_city, leads.primary_address_state,
leads.primary_address_postalcode, leads.primary_address_country,
leads.alt_address_street, leads.alt_address_city, leads.alt_address_state,
leads.alt_address_postalcode, leads.alt_address_country, leads.assistant,
leads.assistant_phone, leads.picture, leads.converted, leads.refered_by,
leads.lead_source, leads.lead_source_description, leads.status, leads.status_description,
leads.reports_to_id, leads.dp_business_purpose, leads.dp_consent_last_updated,
leads.dnb_principal_id, leads.account_name, leads.account_description, leads.contact_id,
leads.account_id, leads.opportunity_id, leads.opportunity_name, leads.opportunity_amount,
leads.campaign_id, leads.birthdate, leads.website, leads.preferred_language,
leads.mkto_sync, leads.mkto_id, leads.mkto_lead_score, leads.assigned_user_id,
leads.team_id, leads.team_set_id, leads_cstm.fb_email_c, leads_cstm.address_not_found_c,
leads_cstm.remarket_c, leads_cstm.salesperson_c, leads_cstm.has_guaranteed_payments_c,
leads_cstm.letter_sent_c, leads_cstm.leadtype_c, leads_cstm.paymentsunsold_c,
leads_cstm.try_alternate_address_c, leads_cstm.lotto_date_won_c, leads_cstm.suffix_c,
leads_cstm.county_court_state_c, leads_cstm.name_insurance_company_c,
leads_cstm.date_called_in_c, leads_cstm.last_mailed_c, leads_cstm.call_back_c,
leads_cstm.payments_unsold_c, leads_cstm.research_comments_c,
leads_cstm.remove_from_mailing_c, leads_cstm.lotto_state_won_c,
leads_cstm.fb_connected_c, leads_cstm.offline_c, leads_cstm.otherphone2_c,
leads_cstm.sold_out_c, leads_cstm.sent_vacation_bonus_c, leads_cstm.called_in_c,
leads_cstm.court_retrieval_c, leads_cstm.deal_filing_date_c, leads_cstm.lotto_game_won_c,
leads_cstm.wrongperson_c, leads_cstm.wrongdiscnumber_c, leads_cstm.middle_initial_c,
leads_cstm.need_more_research_c, leads_cstm.lotto_amount_won_c, leads_cstm.new_address_c,
leads_cstm.return_mail_c, leads_cstm.backfill_case_data_c, leads_cstm.badnumbers_c,
leads_cstm.lastsellercontact_c, leads_cstm.check_number_c, leads_cstm.company_sold_to_c,
leads_cstm.additional_information_c, leads_cstm.phone_verified_c,
leads_cstm.researcher_c, leads_cstm.deal_status_c, leads_cstm.verified_agent_name_c,
leads_cstm.researchcode_c, leads_cstm.haspayments_c, leads_cstm.leadstatus_c,
leads_cstm.follow_up_date_c, leads_cstm.last_researcher_name_c,
leads_cstm.last_researcher_date_c, leads_cstm.filenumber_c, leads_cstm.other_phone_3_c,
leads_cstm.lead_action_c, leads_cstm.status_note_c, leads_cstm.queue_status_c,
leads_cstm.last_worked_c, leads_cstm.follow_up_email_sent_c,
leads_cstm.assignedfromqueue_c, leads_cstm.case_number_c, leads_cstm.netpresentvalue_c,
leads_cstm.phone1_c, leads_cstm.phone2_c, leads_cstm.phone3_c, leads_cstm.phone4_c,
leads_cstm.phone5_c, leads_cstm.phone6_c, leads_cstm.phone7_c, leads_cstm.phone8_c,
leads_cstm.phone9_c, leads_cstm.phone10_c, leads_cstm.phone11_c, leads_cstm.phone12_c,
leads_cstm.primary_lead_status_c, leads_cstm.senttext_c, leads_cstm.batch_update_c,
leads_cstm.annuity_type_c, leads_cstm.lead_ranking_c, leads_cstm.number_of_cases_c,
leads_cstm.secondary_lead_status_c, leads.dri_workflow_template_id,
leads_cstm.research_code_c, leads_cstm.base_rate, leads_cstm.currency_id,
leads_cstm.user_id1_c, leads_cstm.user_id_c FROM leads LEFT JOIN leads_cstm leads_cstm ON
leads_cstm.id_c = leads.id WHERE ((leads_cstm.secondary_lead_status_c = ?) OR

(leads_cstm.secondary_lead_status_c = ?)) AND (leads.deleted = ?)

Outcomes