| |||||||
| Newsletter Everything about our monthly newsletter shuffle. |
|
| | LinkBack | Thread Tools | Display Modes |
| | #21 (permalink) |
| Administrator ![]() ![]() Join Date: Apr 2006 Location: Dubai
Posts: 7,801
| MySQL on Mac Part 2 MySQL on Mac Part 2 by Magnus We’re continuing the MySQL series on how to operate a MySQL installation on your Mac. In the first part (see the March issue of shuffle), we looked at logging into a MySQL database server running on a Mac, as well as how to see what databases are available, and how to create a database. In the second part (see the April issue of shuffle) we covered how to create tables and fields. Now, in the third and final part we will look at how to get data out of a database. To get data out of database we use the Select-statement. It’s called putting a together a query which is an appropriate name because you’re essentially asking a question of the database and seeing what the answer will be. With a Select-statement you basically ask for some information from one or more tables in a database and you give some criteria for what information should be returned. For example, if we have a table called customer and we want all records from it, we type: SELECT * FROM customer; The star (“*”) means we want all fields (columns) returned. If the table has ten fields, we get all ten fields returned. Instead if we want just one field returned, let’s say the name-field, we type: SELECT name FROM customer; And we can also ask for a specific number of fields, like name and email, like this: SELECT name, email FROM customer; That’s how we choose which fields to return. Next, let’s look at how to select which records to return. Let’s say we want to find the customer with the id 5. Then we type: SELECT * FROM customer WHERE id=5; Or if we want to find any customer in Dubai that is of type hotel, then the query is: SELECT * FROM customer WHERE city="Dubai" AND type="hotel"; That’s a very quick introduction to Select-statements. There’s certainly much more to learn but all we wanted to accomplish is to give you a start. From here, if you want to learn more, there are plenty of good books, and many helpful web sites. You can of course also post on www.emiratesmac.com and ask for help. Wrapping Up That concludes our brief series on how to use MySQL on your Mac. We hope you can now go on and work with MySQL or some other SQL-variant on your Mac, and perhaps create databases for your own personal use. It may even be that with this as a basis you can create some dynamic web sites. Look out for a new series on PHP in future issues of shuffle. PHP paired with MySQL is arguably the most popular technology for developing dynamic web sites used on the internet today. |
| |
| Thread Tools | |
| Display Modes | |
| |