The SQL "SELECT" statement will retrieve information from a database table. Learn how to create write a SELECT statement in a Named Query.

Video recorded using: Ignition 8.0


(open in window)

[00:00] In this lesson, we're going to take a look at how to select data out of a table in the database. To start, I'm going to create a new named query and I'm going to call it "Select." I'll go ahead and click the Create button and go to my Authoring tab. As always, I will set my database connection to internal DB, and I'm going to leave my query type at query because I do want to select data out of the database table. I am not going to be using any parameters in this query so I can delete them. I can then paste my query in the query area. To select data out of a table, we first use the command select followed by the names of the columns that we want to select a data out for.

[01:01] So in this case, I am selecting out the name column and the location column and they're separated by a comma. Once I've listed out all of my columns, I then use the from keyword and after that, I put the name of the table that I want to select data from. In this case, inventory. Now that I have my query, I can go to the testing tab and click execute query to test it out. As you can see, I pull out all of the rows of data from the name and location columns out of the inventory table. I can list out whatever combination of columns I want as long as they exist within the table. Finally, if I want to select out the data from all of the columns in the table, then I can use a special symbol instead. Back to my query, rather than listing out the name of every single column within my table, I can simply use the star symbol.

[02:04] When I use the star symbol, instead of naming out columns, the query will automatically grab all columns. To test this out, I'm going to go back to my testing tab and execute my query again. And we can see here that I've now grabbed all three columns: name, location, and quantity, even though I haven't listed them all out.

You are editing this transcript.

Make any corrections to improve this transcript. We'll review any changes before posting them.


Share this video