Apex Syntax: How to better understand the Apex Syntax and Logic in Salesforce?
A free video tutorial from Deepika Khanna
Software Developer,Blogger,Author
47 courses
218,246 students
Learn more from the full course
Salesforce Development Training for Beginners
Salesforce Development :Learn about Apex programming and Salesforce development. Become a Salesforce Developer.
13:36:30 of on-demand video • Updated March 2026
you will have a mastery of programming in Apex no matter what level of experience you are at right now.
My goal is not just to show you how to program, but to help you understand what you are doing, and why you are doing it as well!
Not only do the videos show you how to become a Apex programmer in great detail, but this course also contains lot of assignments to practice.
I'll be constantly adding new material to the course as well as updating it on a regular basis to make sure you access to the best and most update to date and comprehensive Apex training
English [Auto]
Hello, guys. Welcome back. In this tutorial we are going to take a look at Apex syntax. So what are the different things that are available in Apex program? So Apex program has things like variable declaration. You will write SQL queries, loop statements, flow control statements, statements, and what are each of them? We're going to take a look deep dive into those, but let's see what variable declaration looks like. So you can see here the second line that you see. It's a variable declaration. Now what do you mean by a variable? Variable is used to store some data. That is what the variable is used for. So here what we are creating is we are creating a variable to store the list of accounts. If you have more than one account records that you want to store, then in order to store that list you are going to need a placeholder. So that is what we have done here is we are declaring a variable which will be used to store a bunch of account records. Then the second the next statement looks like select ID, comma name description from account. So this is called as an SQL query. Now the SQL query is used to retrieve data from Salesforce. Okay, so if you wanted to pull out information related to an account, okay. If your specific if you're interested in a particular account, you can use this SQL query in order to retrieve the data. Then the next thing is a loop statement. So let's say there are three records that are available or three account records, and in each of those account records you want to update a particular field of all of those records. So what you will do is you will you will go over these records one by one and update that field of every record so those things can be done using the loop statement. So here what you're doing is we are using a for loop and we are iterating over means we are going over the list account, which is nothing but the variable which has the list of account records. So we are going over those records one by one. And then what we are doing is we are updating the description field on those records to something like this and then we are adding back to another list. So this is what the loop statements looks like. So if you wanted to iterate over records one by one or if you want to update something in, let's say ten records or ten account records, so what you're going to do, you're going to go ahead and update using the for loop. You will iterate over those records and update the field. Then you have is flow control statements. Now, what do you mean by flow Control means if there is a if you want to achieve something based on a particular condition. So that is called as flow control. So if you're checking if the account update is not equal to null or if the size of the list is greater than zero, then do this. So this is what if. Else condition list flow control means. If you want to do something based on a particular condition and if that condition is met, do this. If that condition did not met, do something else. So those are called as flow control statements. We'll talk about those in this course as well. Then we have this DML statements. As I told you, those are called data manipulation language, which means if you want to manipulate the data, if you want to update something, if you want to insert a record into Salesforce, then you're going to use these statements. So the statement looks like this. So you're making an update. Do Salesforce this account. So what you're doing here is you are doing an update to this particular record. So whatever you have, whatever whatever the records you have inside of this variable, all of those will get updated using this update statement. So this is how the DML statements looks like. So these are the different features or these are the different things that you're going to use inside of your apex. And these are the things that makes the Apex program. So we'll have variable declarations. You will need some SQL query to retrieve the data to iterate over the data to use if else conditions to write DML statements, etcetera. So this is what an Apex program will look like. Now in the next tutorial we are going to start with a very basic which is called what is a variable and how do we declare a variable in apex. So I'll see you then. Thank you so much.