Help us understand the problem. What is going on with this article?

Salesforce開発者コンソールでSQL文実行

More than 1 year has passed since last update.

■SOQLステートメントを実行する
開発者コンソールで、[Query Editor (クエリエディタ)] をクリックします。
SELECT Id, Name, Session_Date_c, Levelc FROM Sessionc WHERE Level_c = 'Advanced' LIMIT 1

■DMLステートメントを実行する
開発者コンソールで、[Debug (デバッグ)] > [Open Execute Anonymous Window (実行匿名ウィンドウを開く)] をクリックし、次のステートメントを実行してセッションを更新します
List taskList = [SELECT Id, Status_c FROM Taskc WHERE Companyc = 'PS'];
List<Task
c> updTaskList = new List<Taskc>();
for (Task
c item : taskList) {
item.Status
_c = 30;
updTaskList.add(item);
}
update updTaskList;

■参照URL
SOQL と DML を使用したデータへのアクセス
https://trailhead.salesforce.com/ja/content/learn/projects/salesforce_developer_workshop/accessing_data_with_soql_and_dml

http://salesforcedevelopersjapan.github.io/salesforce-developer-workshop/Accessing-Data-using-SOQL-and-DML.html

【SOQL】Salesforce開発者コンソール(Query)の使い方
https://qiita.com/szaizen/items/be99e97f74b45bdf3d0a

Apex DML Statements
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dml_section.htm#!

Write SOSL Queries Unit | Salesforce Trailhead
https://trailhead.salesforce.com/en/content/learn/modules/apex_database/apex_database_sosl


Child-to-parent:子 (Contact) から親 (Account) を参照
SELECT Id, Name, Account.Id, Account.Name FROM Contact

Parent-to-child:親 (Account) から子 (Contact) を参照
SELECT Id, Name, (SELECT Id FROM Contacts) FROM Account

Child-to-parent:子(ChildObj_c)から親(ParentObjc)を参照
SELECT Id, Name, ParentObj
c, ParentObjr.name FROM ChildObj_c

Parent-to-child:親(ParentObj_c)から子(ChildObjc)を参照
SELECT Id, Name, (SELECT Id, Name FROM [子リレーション名]
r) FROM ParentObj_c

Apexコードでの利用例
子(ChildObj_c)から親(ParentObj_c)を参照

List children = [SELECT Id, Name, ParentObj_c, ParentObjr.name FROM ChildObjc];
// 親オブジェクトのnameフィールドの値を表示
System.debug(children.parentObj
_r.name);

親(ParentObj_c)から子(ChildObjc)を参照
List<ParentObj
c> parents = [SELECT Id, Name, (SELECT Id, Name FROM ChildObjsr) FROM ParentObjc];
// 子オブジェクトのnameフィールドの値を表示
for (ChildObj
c child : parents.childObjs_r) {
System.debug(child.name);
}

https://dackdive.hateblo.jp/entry/2014/06/10/112629
[Salesforce]参照関係にあるオブジェクトをSOQLで取得する

参照関係にある複数のオブジェクトのデータ取得
[子→親オブジェクトへのデータ参照]
SELECT Id, Name, parent.Id, parent.Name FROM Child;

[親→子オブジェクトへのデータ参照]

SELECT Id, Name, (SELECT Id, Name FROM Child)FROM Parent;

[参照関係にある2つのオブジェクトから1つのオブジェクトの項目のみ取得]
SELECT Id, NameFROM tableAWHERE Id IN (SELECT Id from tableB);

SELECT StageName, SUM(Amount) OppAmount, COUNT(id) Total
FROM Opportunity
WHERE isClosed=False
GROUP BY StageName
HAVING count(ID) >1

AggregateResult [] opps = [ SELECT StageName, SUM(Amount) OppAmount, COUNT(id) Total FROM Opportunity where isClosed=False GROUP BY StageName HAVING count(ID) >1 ];
System.debug(opps[0].OppAmount);

Sorting Data using ORDER BY:
Select Id, Name From Opportunity ORDER BY Name ASC

LIMIT the Rows using OFFSET and LIMIT:
SELECT Name FROM Opportunity LIMIT 50 OFFSET 100

Dynamic SOQL
String myString = 'John Smith';
List sobjList = Database.query('SELECT Id, Name FROM Account WHERE Name = :myString');

https://apexcoder.com/2016/01/02/how-to-use-soql-query-with-nested-soql-aggregate-functions-order-by-group-by-having-offset-and-limit/
Select Id, Name From Account LIMIT 10
Select Contact.Account.Name From Contact (1 level up )
Select Id, ( Select Id from Contacts ) From Account
Select Id, Name, (Select Id From Contacts), (Select Id From Cases) from Account LIMIT 10

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした