There's moreā€¦

The INNER JOIN statement used in the preceding example joins two tables together and selects all rows from both tables, as long as there is a match between the columns in both tables. There are many other types of JOIN statements that you can use in MySQL (and some other types of SQL architecture), such as LEFT JOIN, RIGHT JOIN, and FULL OUTER JOIN.

The following diagram shows the different types of JOIN statements and their effects:

The following bullet points explain the LIKE and DISTINCT statements, which we used in our example code in this recipe:

  • The LIKE statement is normally used to search for a string variable in the database without the full word. Notice that there are two % symbols, located before and after the search keyword.
  • The DISTINCT statement used in the previous example filters out results that have the exact same variable. For example, without the DISTINCT statement, you will see two versions of Larry King appear in the terminal because there are two records of him logging into the system on the same day. By adding the DISTINCT statement, MySQL will eliminate one of the results and ensure every result is unique.
  • You may be wondering what d-MMMM-yyyy stands for and why we used it in the preceding example. That is actually an expression supplied to the QDateTime class in Qt to display the date-time result using a given format. In this case, it will change the date-time data that we get from MySQL, 2019-08-06, to the format that we specified, resulting in 6-August-2019.

For more information, check out Qt's documentation at http://doc.qt.io/qt-5/qdatetime.html#toString, which has the full list of expressions that can be used to determine the format of the date and time string.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset