

Getting members listing showing the year of birth The above query with a more meaningful column name SELECT Concat(`title`, ' (', `director`, ')') AS 'Concat', `year_released` FROM `movies`
#Mysql syntax code
The above example returned the Concatenation code as the field name for our results. Pirates of the Caribean 4 ( Rob Marshall)įorgetting Sarah Marshal (Nicholas Stoller) String portions are separated using commas in the Concat () function.Įxecuting the above script in MySQL workbench produces the following result set.

The line “Concat (`title`, ‘ (‘, `director`, ‘)’) gets the title, adds an opening bracket followed by the name of the director then adds the closing bracket. The Concat () MySQL function is used join the columns values together. SELECT Concat(`title`, ' (', `director`, ')'), `year_released` FROM `movies`
#Mysql syntax movie
We also want to get the year that the movie was released. The name of the movie director should be in brackets. We want to have the movie title and the name of the movie director in one field. Let’s say we want to get a list of movie from our database. Remember in our above discussion that we mention expressions been used in SELECT statements. SELECT `full_names`,`gender`,`physical_address`, `email` FROM `members` Įxecuting the above script in MySQL workbench produces the following results. The following script would help us to achieve this. Let’s say we are only interested in getting only the full_names, gender, physical_address and email fields only. Our above query has returned all the rows and columns from the members table. SELECT * FROM `members` Įxecuting the above script in MySQL workbench produces the following results. Let’s suppose that we want to get a list of all the registered library members from our database, we would use the script shown below to do that. Table 1: members table membership_ number The Examples are performed on the following two tables
#Mysql syntax download
It’s not mandatory but is considered a good practice to end your statements like that.Ĭlick to download the myflix DB used for practical examples. The above statement selects all the fields from the members table. An example of a simple SELECT statement looks like the one shown below. The Star symbol is used to select all the columns in table.

Databases store data for later retrieval. SELECT QUERY is used to fetch the data from the MySQL database.
