You need to sign in to do that
Don't have an account?
anuragsinghns
get 1 value per item in List SOQL Query
hi guys,
I was wondering if there is a way I can write a query which would return me one value for a corresponding match in a list.
Example say this is my set {'one','two','three'} lets call it mynameSet
and I write a query
list<account> myaccounts =[select id,Name from account where name=:mynameSet];
now in my system if I have 4 accounts like this below
Name
Account 1- one
Account 2- two
Account 3- three
Account 4- one
I want my query to return only three records not all 4 it should pick a either account1 or account4 I was also wondering if this is not possible to do so in a query what would be the best way to solve this issue without having the SOQL query return large amount of records.
I was wondering if there is a way I can write a query which would return me one value for a corresponding match in a list.
Example say this is my set {'one','two','three'} lets call it mynameSet
and I write a query
list<account> myaccounts =[select id,Name from account where name=:mynameSet];
now in my system if I have 4 accounts like this below
Name
Account 1- one
Account 2- two
Account 3- three
Account 4- one
I want my query to return only three records not all 4 it should pick a either account1 or account4 I was also wondering if this is not possible to do so in a query what would be the best way to solve this issue without having the SOQL query return large amount of records.
All Answers
Thanks again for all your Help!