HomeForumsEMUG User GroupShuffle NewsletterTrainingAppleIDX PricesGalleryCalendarAboutContactSearch

Go Back   EmiratesMac > EMUG > Newsletter
Register FAQ Members List Search Today's Posts Mark Forums Read Log Out

Newsletter Everything about our monthly newsletter shuffle.


Welcome to EmiratesMac! Join EmiratesMac today! Contact us!
Closed Thread
 
LinkBack Thread Tools Display Modes
Old 17th May 2007, 08:39   #21 (permalink)
Administrator

 
Magnus's Avatar
 
Join Date: Apr 2006
Location: Dubai
Posts: 7,801
Magnus has a reputation beyond reputeMagnus has a reputation beyond reputeMagnus has a reputation beyond reputeMagnus has a reputation beyond reputeMagnus has a reputation beyond reputeMagnus has a reputation beyond reputeMagnus has a reputation beyond reputeMagnus has a reputation beyond reputeMagnus has a reputation beyond reputeMagnus has a reputation beyond reputeMagnus has a reputation beyond repute
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.


Magnus is offline  
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Closed Thread


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Apple, the Apple Logo, and Macintosh are trademarks of Apple, Inc., registered in the U.S.A. and other countries. EmiratesMac is a recognized independent user group and has not been authorized, sponsored, or otherwise approved by Apple, Inc.
All times are GMT +4. The time now is 01:22.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0