The basic syntax of these commands is very simple, as you??™ll see in the following pages.
However, keep in mind that SQL is a very flexible and powerful language and can be used to
create much more complicated and powerful queries than what you see here. You??™ll learn
more while building the web site, but for now, let??™s take a quick look at the basic syntax. For more
details about any of these commands, you can always refer to their official documentation:
??? http://www.mysql.org/doc/refman/5.1/en/select.html
??? http://www.mysql.org/doc/refman/5.1/en/insert.html
??? http://www.mysql.org/doc/refman/5.1/en/update.html
??? http://www.mysql.org/doc/refman/5.1/en/delete.html
SELECT
The SELECT statement is used to query the database and retrieve selected data that match the
criteria you specify. Its basic structure is
SELECT
[FROM ]
[WHERE ]
?– Note In this book, the SQL commands and queries appear in uppercase for consistency and clarity
although SQL is not case sensitive. The WHERE and FROM clauses appear in brackets because they are
optional.
CHAPTER 4 ?– CREATING THE PRODUCT CATALOG: PART 1 79
The following command returns the name of the department that has the department_id
of 1. In your case, the returned value is Regional, but you would receive no results if there was
no department with an ID of 1.
Pages:
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156