The dummy data that we created earlier are stored in an SQL Server instance. Select Empty from the list of templates and click Create: Connecting SQL Server with Visual Studio You will see several options for your ASP.NET Web Application: Next, give your project a custom name and click Create: Open a new project in the Visual Studio and select ASP.NET Web Application (.NET Framework) with the C# template from the list: We will create the ASP.NET webforms application with the Microsoft Visual Studio IDE. Displaying INNER JOIN Result in HTML5 Table with ASP.NET Webform It will connect to an SQL Server database and display the HTML5 table with the results of our INNER JOIN query. Now that we’ve clarified what INNER JOIN is and how it works, let’s create an ASP.NET application. Thus, the INNER JOIN query did not return the corresponding rows from the Authors table. However, these IDs are absent in the AuthorIdF column of the Books table. Similarly, the Authors table includes such Authors’ IDs as 1, 2, and 25. Hence, the query did not return results for corresponding books. However, there weren’t authors with such IDs in the Authors table. Note: The original Books table contained such Author Ids as 8,9, and 10. It was in the AuthorIdF column ( Books table) and the AuthorId column ( Authors table). Here the result is:Īs you can see, the query returned those rows only where both the Books and Authors tables had a common value. This script implements an INNER JOIN query on two columns: the AuthorId column from the Authors table and the AuthorIdF column from the Books table. SELECT Books.BookName, Books.BookPrice, Authors.AuthorName, Authors.AuthorId However, we need first to write an INNER JOIN query and see the results it provides.Įxecute the following script: USE Library You will see it yourself when observing the INNER JOIN query results.įurther, we’ll create an ASP.NET webform that will display the INNER join query results, combining the data from both the Authors and Books tables. It might sound complicated but it is not. The SQL INNER JOIN query returns rows from different tables that have specific common values matching in several columns where we apply the JOIN query. How does the SQL Server INNER JOIN Query Work? The following script adds dummy records to our dataset: INSERT INTO Authors We’ll use this column as a foreign key column to store the Authors’ IDs from the Authors table. Notice that the Books table has a column AuthorIdF. The next script adds the Authors and Books tables to the Library database. Of course, in reality, one book can have several co-authors, but we won’t deal with this case here.Įxecute the following script to create a dummy database named Library: CREATE DATABASE Library Here, we’ll work with a library database containing two tables, Authors and Books.Īuthors and Books will relate as “one-to-many” – we assume that one author can write several books, but a book can have only a single author. Additionally, it touches on the question of using CSS3 (cascading style sheets) to apply a style to the HTML5 table in an ASP.NET webform.īefore querying an SQL server database to display results in the HTML5 table, we need to have some data in that database. This article describes the ways of using an INNER JOIN to combine results from two tables in the SQL Server database and display them in an HTML5 table inside an ASP.NET webform.