Is there any use for defining additional entity types in a SOQL FROM clause? The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) 2019 Moderator Election Q&A - Questionnaire 2019 Community Moderator Election Resultsquery user and profileSOQL relationship name syntax errorDynamic SOQL bindingWhat is wrong with my relationship?How to query all records changed since date?SOQL for Lookup relationshipLeft join in Bulk APISelect where not exists / count(otherRecord) = 0How can we Get the records of contacts where phone= account.phone?What types of fields are groupable in a SOQL `GROUP BY` clause?SOQL Search function of Contact Name With Account Parent to Contact Child

Didn't get enough time to take a Coding Test - what to do now?

Install many applications using one command

First use of “packing” as in carrying a gun

How to delete random line from file using Unix command?

Why not take a picture of a closer black hole?

Change bounding box of math glyphs in LuaTeX

Working through the single responsibility principle (SRP) in Python when calls are expensive

Hopping to infinity along a string of digits

When did F become S in typeography, and why?

Are spiders unable to hurt humans, especially very small spiders?

Finding the path in a graph from A to B then back to A with a minimum of shared edges

Am I ethically obligated to go into work on an off day if the reason is sudden?

Would it be possible to rearrange a dragon's flight muscle to somewhat circumvent the square-cube law?

What can I do if neighbor is blocking my solar panels intentionally?

What's the point in a preamp?

Why can't wing-mounted spoilers be used to steepen approaches?

Segmentation fault output is suppressed when piping stdin into a function. Why?

Would an alien lifeform be able to achieve space travel if lacking in vision?

How to pronounce 1ターン?

Match Roman Numerals

Do warforged have souls?

Keeping a retro style to sci-fi spaceships?

Windows 10: How to Lock (not sleep) laptop on lid close?

How is simplicity better than precision and clarity in prose?



Is there any use for defining additional entity types in a SOQL FROM clause?



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
2019 Moderator Election Q&A - Questionnaire
2019 Community Moderator Election Resultsquery user and profileSOQL relationship name syntax errorDynamic SOQL bindingWhat is wrong with my relationship?How to query all records changed since date?SOQL for Lookup relationshipLeft join in Bulk APISelect where not exists / count(otherRecord) = 0How can we Get the records of contacts where phone= account.phone?What types of fields are groupable in a SOQL `GROUP BY` clause?SOQL Search function of Contact Name With Account Parent to Contact Child



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








7















Here's a somewhat odd SOQL query from the question query user and profile:



select user.id, user.Email,user.FirstName,user.LastName,user.profile.name,user.Username,user.IsActive 
from user, user.profile


Note that the FROM clause includes both user and user.profile.



Here is a simpler example to follow the Contact to Account relationship:



select Id, Name, Account.Name from Contact, Contact.Account


The same query with the relationship join can be performed with:



Select Id, Name, Account.Name From Contact


Is there any purpose to supporting additional SObject types in the from clause, or is it vestigial?



Is is outlined as supported syntax in SOQL.




SELECT fieldList [subquery][...]

[TYPEOF typeOfField whenExpression[...] elseExpression END][...]

FROM objectType[,...]

[USING SCOPE filterScope]




Out of interest, if you don't use a valid sObject relationship on the additional sObject types you get the following message:



INVALID_TYPE: 
Name, Account.Name From Contact, Account
^
ERROR at Row:1:Column:45
A driving SObject type has already been set, all other entity types in the FROM clause must
be relationships to the initial object. The driving object is Contact.



While doing some checking I found this old dev forum question that indicated it was added to the syntax in Winter '15. Or at least documented then. - Missing doc for new SOQL multiple object SELECT?










share|improve this question






















  • Ah, I finally know how this strange syntax can actually be used. No idea on what it actually does though. Maybe it helps with choosing indices to use, or helps disambiguate multiple references to the same related SObject?

    – Derek F
    Apr 9 at 1:26











  • @DerekF Currently is seems redundant. Like it was maybe a left over from the SQL query origins. I'm still not sure what it would help disambiguate. Maybe for polymorphic relationships?

    – Daniel Ballinger
    Apr 9 at 1:36

















7















Here's a somewhat odd SOQL query from the question query user and profile:



select user.id, user.Email,user.FirstName,user.LastName,user.profile.name,user.Username,user.IsActive 
from user, user.profile


Note that the FROM clause includes both user and user.profile.



Here is a simpler example to follow the Contact to Account relationship:



select Id, Name, Account.Name from Contact, Contact.Account


The same query with the relationship join can be performed with:



Select Id, Name, Account.Name From Contact


Is there any purpose to supporting additional SObject types in the from clause, or is it vestigial?



Is is outlined as supported syntax in SOQL.




SELECT fieldList [subquery][...]

[TYPEOF typeOfField whenExpression[...] elseExpression END][...]

FROM objectType[,...]

[USING SCOPE filterScope]




Out of interest, if you don't use a valid sObject relationship on the additional sObject types you get the following message:



INVALID_TYPE: 
Name, Account.Name From Contact, Account
^
ERROR at Row:1:Column:45
A driving SObject type has already been set, all other entity types in the FROM clause must
be relationships to the initial object. The driving object is Contact.



While doing some checking I found this old dev forum question that indicated it was added to the syntax in Winter '15. Or at least documented then. - Missing doc for new SOQL multiple object SELECT?










share|improve this question






















  • Ah, I finally know how this strange syntax can actually be used. No idea on what it actually does though. Maybe it helps with choosing indices to use, or helps disambiguate multiple references to the same related SObject?

    – Derek F
    Apr 9 at 1:26











  • @DerekF Currently is seems redundant. Like it was maybe a left over from the SQL query origins. I'm still not sure what it would help disambiguate. Maybe for polymorphic relationships?

    – Daniel Ballinger
    Apr 9 at 1:36













7












7








7


1






Here's a somewhat odd SOQL query from the question query user and profile:



select user.id, user.Email,user.FirstName,user.LastName,user.profile.name,user.Username,user.IsActive 
from user, user.profile


Note that the FROM clause includes both user and user.profile.



Here is a simpler example to follow the Contact to Account relationship:



select Id, Name, Account.Name from Contact, Contact.Account


The same query with the relationship join can be performed with:



Select Id, Name, Account.Name From Contact


Is there any purpose to supporting additional SObject types in the from clause, or is it vestigial?



Is is outlined as supported syntax in SOQL.




SELECT fieldList [subquery][...]

[TYPEOF typeOfField whenExpression[...] elseExpression END][...]

FROM objectType[,...]

[USING SCOPE filterScope]




Out of interest, if you don't use a valid sObject relationship on the additional sObject types you get the following message:



INVALID_TYPE: 
Name, Account.Name From Contact, Account
^
ERROR at Row:1:Column:45
A driving SObject type has already been set, all other entity types in the FROM clause must
be relationships to the initial object. The driving object is Contact.



While doing some checking I found this old dev forum question that indicated it was added to the syntax in Winter '15. Or at least documented then. - Missing doc for new SOQL multiple object SELECT?










share|improve this question














Here's a somewhat odd SOQL query from the question query user and profile:



select user.id, user.Email,user.FirstName,user.LastName,user.profile.name,user.Username,user.IsActive 
from user, user.profile


Note that the FROM clause includes both user and user.profile.



Here is a simpler example to follow the Contact to Account relationship:



select Id, Name, Account.Name from Contact, Contact.Account


The same query with the relationship join can be performed with:



Select Id, Name, Account.Name From Contact


Is there any purpose to supporting additional SObject types in the from clause, or is it vestigial?



Is is outlined as supported syntax in SOQL.




SELECT fieldList [subquery][...]

[TYPEOF typeOfField whenExpression[...] elseExpression END][...]

FROM objectType[,...]

[USING SCOPE filterScope]




Out of interest, if you don't use a valid sObject relationship on the additional sObject types you get the following message:



INVALID_TYPE: 
Name, Account.Name From Contact, Account
^
ERROR at Row:1:Column:45
A driving SObject type has already been set, all other entity types in the FROM clause must
be relationships to the initial object. The driving object is Contact.



While doing some checking I found this old dev forum question that indicated it was added to the syntax in Winter '15. Or at least documented then. - Missing doc for new SOQL multiple object SELECT?







soql






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Apr 9 at 1:12









Daniel BallingerDaniel Ballinger

74.6k15155408




74.6k15155408












  • Ah, I finally know how this strange syntax can actually be used. No idea on what it actually does though. Maybe it helps with choosing indices to use, or helps disambiguate multiple references to the same related SObject?

    – Derek F
    Apr 9 at 1:26











  • @DerekF Currently is seems redundant. Like it was maybe a left over from the SQL query origins. I'm still not sure what it would help disambiguate. Maybe for polymorphic relationships?

    – Daniel Ballinger
    Apr 9 at 1:36

















  • Ah, I finally know how this strange syntax can actually be used. No idea on what it actually does though. Maybe it helps with choosing indices to use, or helps disambiguate multiple references to the same related SObject?

    – Derek F
    Apr 9 at 1:26











  • @DerekF Currently is seems redundant. Like it was maybe a left over from the SQL query origins. I'm still not sure what it would help disambiguate. Maybe for polymorphic relationships?

    – Daniel Ballinger
    Apr 9 at 1:36
















Ah, I finally know how this strange syntax can actually be used. No idea on what it actually does though. Maybe it helps with choosing indices to use, or helps disambiguate multiple references to the same related SObject?

– Derek F
Apr 9 at 1:26





Ah, I finally know how this strange syntax can actually be used. No idea on what it actually does though. Maybe it helps with choosing indices to use, or helps disambiguate multiple references to the same related SObject?

– Derek F
Apr 9 at 1:26













@DerekF Currently is seems redundant. Like it was maybe a left over from the SQL query origins. I'm still not sure what it would help disambiguate. Maybe for polymorphic relationships?

– Daniel Ballinger
Apr 9 at 1:36





@DerekF Currently is seems redundant. Like it was maybe a left over from the SQL query origins. I'm still not sure what it would help disambiguate. Maybe for polymorphic relationships?

– Daniel Ballinger
Apr 9 at 1:36










1 Answer
1






active

oldest

votes


















7














One possible use is to use is to combine it with the Alias notation for the related sObjects.



E.g.



select c.Id, c.Name, ca.Name, art.Name 
from Contact c, Contact.Account ca, Contact.Account.RecordType art


If you wanted to query many fields from the related sObject then you could save a significant number of characters if you are running up against the 20,000 character limit.






share|improve this answer


















  • 2





    Even if you don't care about the query limit, it can be nice to save all that typing!

    – Adrian Larson
    Apr 9 at 17:01











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "459"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f257078%2fis-there-any-use-for-defining-additional-entity-types-in-a-soql-from-clause%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









7














One possible use is to use is to combine it with the Alias notation for the related sObjects.



E.g.



select c.Id, c.Name, ca.Name, art.Name 
from Contact c, Contact.Account ca, Contact.Account.RecordType art


If you wanted to query many fields from the related sObject then you could save a significant number of characters if you are running up against the 20,000 character limit.






share|improve this answer


















  • 2





    Even if you don't care about the query limit, it can be nice to save all that typing!

    – Adrian Larson
    Apr 9 at 17:01















7














One possible use is to use is to combine it with the Alias notation for the related sObjects.



E.g.



select c.Id, c.Name, ca.Name, art.Name 
from Contact c, Contact.Account ca, Contact.Account.RecordType art


If you wanted to query many fields from the related sObject then you could save a significant number of characters if you are running up against the 20,000 character limit.






share|improve this answer


















  • 2





    Even if you don't care about the query limit, it can be nice to save all that typing!

    – Adrian Larson
    Apr 9 at 17:01













7












7








7







One possible use is to use is to combine it with the Alias notation for the related sObjects.



E.g.



select c.Id, c.Name, ca.Name, art.Name 
from Contact c, Contact.Account ca, Contact.Account.RecordType art


If you wanted to query many fields from the related sObject then you could save a significant number of characters if you are running up against the 20,000 character limit.






share|improve this answer













One possible use is to use is to combine it with the Alias notation for the related sObjects.



E.g.



select c.Id, c.Name, ca.Name, art.Name 
from Contact c, Contact.Account ca, Contact.Account.RecordType art


If you wanted to query many fields from the related sObject then you could save a significant number of characters if you are running up against the 20,000 character limit.







share|improve this answer












share|improve this answer



share|improve this answer










answered Apr 9 at 1:50









Daniel BallingerDaniel Ballinger

74.6k15155408




74.6k15155408







  • 2





    Even if you don't care about the query limit, it can be nice to save all that typing!

    – Adrian Larson
    Apr 9 at 17:01












  • 2





    Even if you don't care about the query limit, it can be nice to save all that typing!

    – Adrian Larson
    Apr 9 at 17:01







2




2





Even if you don't care about the query limit, it can be nice to save all that typing!

– Adrian Larson
Apr 9 at 17:01





Even if you don't care about the query limit, it can be nice to save all that typing!

– Adrian Larson
Apr 9 at 17:01

















draft saved

draft discarded
















































Thanks for contributing an answer to Salesforce Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsalesforce.stackexchange.com%2fquestions%2f257078%2fis-there-any-use-for-defining-additional-entity-types-in-a-soql-from-clause%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Wikipedia:Vital articles Мазмуну Biography - Өмүр баян Philosophy and psychology - Философия жана психология Religion - Дин Social sciences - Коомдук илимдер Language and literature - Тил жана адабият Science - Илим Technology - Технология Arts and recreation - Искусство жана эс алуу History and geography - Тарых жана география Навигация менюсу

Bruxelas-Capital Índice Historia | Composición | Situación lingüística | Clima | Cidades irmandadas | Notas | Véxase tamén | Menú de navegacióneO uso das linguas en Bruxelas e a situación do neerlandés"Rexión de Bruxelas Capital"o orixinalSitio da rexiónPáxina de Bruselas no sitio da Oficina de Promoción Turística de Valonia e BruxelasMapa Interactivo da Rexión de Bruxelas-CapitaleeWorldCat332144929079854441105155190212ID28008674080552-90000 0001 0666 3698n94104302ID540940339365017018237

What should I write in an apology letter, since I have decided not to join a company after accepting an offer letterShould I keep looking after accepting a job offer?What should I do when I've been verbally told I would get an offer letter, but still haven't gotten one after 4 weeks?Do I accept an offer from a company that I am not likely to join?New job hasn't confirmed starting date and I want to give current employer as much notice as possibleHow should I address my manager in my resignation letter?HR delayed background verification, now jobless as resignedNo email communication after accepting a formal written offer. How should I phrase the call?What should I do if after receiving a verbal offer letter I am informed that my written job offer is put on hold due to some internal issues?Should I inform the current employer that I am about to resign within 1-2 weeks since I have signed the offer letter and waiting for visa?What company will do, if I send their offer letter to another company