MySQL for the Absolute Beginner: Select Data from Multiple Tables

In this blog post, I use a very simple example to answer the question how to select data from two different tables in a MySQL database.

Start with creating a database. Now create 2 tables:

CREATE TABLE t1 (col1 VARCHAR(1),col2 INT(1));
CREATE TABLE t2 (col3 VARCHAR(1),col4 INT(1));
INSERT INTO t1 VALUES (‘a’,1),(‘b’,2),(‘c’,3);
INSERT INTO t2 VALUES (‘x’,1),(‘y’,2),(‘z’,3);

Now do a joined select and notice that you can one very big table:

SELECT * FROM t1,t2

output:
a     1     x     1
b     2     x     1
c     3     x     1
a     1     y     2
b     2     y     2
c     3     y     2
a     1     z     3
b     2     z     3
c     3     z     3

However, if col2 of t1 and col4 of t2 are identifiers for the same subjects, we can use these keys to display only rows that make sense:

SELECT * FROM t1,t2 WHERE col2=col4

output:
a     1     x     1
b     2     y     2
c     3     z     3

We can adjust this statement to get only the information we want, e.g. all information from both tables about subject x:

SELECT * FROM t1,t2 WHERE col2=col4 AND col3=’x’

Suppose that the two columns col2 and col4 have the same name, e.g. ‘id’ (which would make sense) then we would write:

SELECT * FROM t1,t2 WHERE t1.id=t2.id AND col3=’x’

and if we only need to know col1 (because the id column is really just an identifier and doesn’t contain information we need and we use col2 to identify subject x, which is information we already have) then we can write:

SELECT col1 FROM t1,t2 WHERE t1.id=t2.id AND col3=’x’

output:
a

Installer Maker 1.7.4Sb01 Available for Testing!

Installer Maker is a programme that wraps your software in a nice and easy installer. Installer Maker 1.7.4Sb01 contains more than 20 new features and bug fixes. Installer Maker creates installers of your software for Mac OS X and Windows and is especially convenient for users of RAD environments such as RealStudio, SuperCard and LiveCode.

Currently, the official standalone version of Installer Maker is 1.6.1. This version is almost a year old. During that year, we added many new features, which were included in the plugin version for LiveCode but not in the standalone version. We are now releasing Installer Maker 1.7.4Sb01, which includes all new features.

Pastedgraphic-1

Note that 1.7.4Sb01 is a beta version. It may work or fail completely. Economy-x-Talk doesn’t bear any responsibility for any problems caused by Installer Maker. See also our business terms and the license included with the software.

There are 4 different versions (for Mac OS X PPC, Mac OS X Intel, Mac OS X Universal and for Windows), which you can download here.

Do you like Installer Maker? You can buy a license with a 25% discount until Friday 9 March! Go to http://qery.us/1v7 to get your discount! The discount applies to both the standalone and the plugin version of Installer Maker.

Installer Maker 1.7.4Sb01 Available for Testing!

Installer Maker is a programme that wraps your software in a nice and easy installer. Installer Maker 1.7.4Sb01 contains more than 20 new features and bug fixes. Installer Maker creates installers of your software for Mac OS X and Windows and is especially convenient for users of RAD environments such as RealStudio, SuperCard and LiveCode.

Currently, the official standalone version of Standalone Maker is 1.6.1. This version is almost a year old. During that year, we added many new features, which were included in the plugin version for LiveCode but not in the standalone version. We are now releasing Installer Maker 1.7.4Sb01, which includes all new features.

Pastedgraphic-1

Note that 1.7.4Sb01 is a beta version. It may work or fail completely. Economy-x-Talk doesn’t bear any responsibility for any problems caused by Installer Maker. See also our business terms and the license included with the software.

There are 4 different versions (for Mac OS X PPC, Mac OS X Intel, Mac OS X Universal and for Windows), which you can download here. Do you like Installer Maker? You can buy a license with a 25% discount until Friday 9 March! Go to http://qery.us/1v7 to get your discount! The discount applies to both the standalone and the plugin version of Installer Maker.

Installer Maker Plugin for LiveCode 25% Off

It’s Spring and that’s a good time to do something nice. Economy-x-Talk is offering all new customers a 25% discount on a license for the Installer Maker Plugin for LiveCode. IM for LC is an easy way to make installers for Windows and Mac OS X with nothing but LiveCode. Please go to http://qery.us/1v7 for more info about the discount and the Installer Maker Plugin. The discount is available until Friday 9th March 2012.

Show and Hide Backdrop in LiveCode with AppleScript

Sometimes, I need to make screenshots of LiveCode applications with a white background. Because LiveCode’s backdrop is black by default and I scripts may set the backdrop to a different colour, I often have to set the backdrop to white from the message box. To avoid the need for typing, I decided to make a simple AppleScript script to set the backdrop to white:

set myScript to “trynif the backdrop is not “none” then set the backdrop to none else set the backdrop to whitencatch myErrnreturn myErrnend try”
tell application “LiveCode 5.0.2”
    do script myScript
    return myScript
end tell

I have save the script and created a user scripts folder in the Scripts menu as shown in the picture below.

Screen_shot_2012-02-08_at_02

Now, whenever I select the script from the menu, the backdrop is set to none if a backdrop is currently visible and it is set to white of no backdrop is currently visible.

Strõm 1.2.1 is now available!

We have updated Strõm Flow Chart Software! This new version includes the possibility to add arrows to the connections between shapes!

Strõm is a programme to draw Strõm charts quickly and easily. Use it to create a visual representation of an organisation, a technical process, a production process, a management hierarchy, a mind map, or anything else that needs a systematic, structured view.

Download Strõm Flow Chart Software at http://flowproject.economy-x-talk.com/

Installer Maker Plugin 1.7 for LiveCode

I’m pleased to announce that after 6 months of hard work Economy-x-Talk is releasing Installer Maker 1.7.

Installer Maker is a plug-in for LiveCode, which allows you to wrap your standalones in an installer with only LiveCode itself –no additional software needed.

This version contains 16 new features, including pre- and post-installation scripts and addition of an icon to the Dock in Mac OS X. All new features are listed on the website.

Screenshot_vista

Installer Maker 1.7 is a free update for everyone who bought a license after 1 October 2011. If your license is more than 3 but less than 12 months old, then you get 50% discount on a new license.

Installer Maker 1.7 is available at http://qery.us/za where you also obtain a license.

Feel free to write any feature requests, bug reports or comments about Installer Maker in the comments below.

Laat MySQL and PHP met elkaar communiceren op Mac OS X 10.5 en 10.6

(This is a post in Dutch only)

Zojuist vond ik onderstaande instructies, die ik geruime tijd geleden voor een forum schreef. Wellicht is dit bruikbaar voor wie PHP en MySQL op zijn eigen Mac wil gebruiken. De instructies betreffen Mac OS X 10.5 en 10.6.

Bijna altijd wordt er met de term MAMP gegooid zo gauw mensen problemen hebben met PHP en MySQL op Mac OS X. Het is onzin om MAMP op een Mac te installeren omdat bijna alles al geïnstalleerd is. Waarom zou je alle serversoftware twee keer installeren? Dat neem alleen maar onnodige ruimte. Je hoeft MAMP echt niet te gebruiken. Je moet gewoon even weten hoe je PHP en MySQL moet configureren.

Voordat PHP met MySQL kan werken, dien je natuurlijk MySQL te installeren. Je kunt MySQL voor Mac OS X hier http://www.mysql.com/downloads/mysql/ downloaden. Installeer MySQL en vergeet niet ook het voorkeurenpaneel te installeren.

Nu kun je PHP activeren. Type command-shift-G en type /etc/apache2/ in het venstertje dat verschijnt. Klik op Ga (of Go) en zoek naar het bestand httpd.conf in die map. Kopieer dit bestand naar de desktop en maak een extra kopie met de naam httpd.conf.oud.
Open het bestand httpd.conf in TextEdit en zoek de regel met
#LoadModule php5_module libexec/httpd/libphp5.so

Verwijder de # en bewaar het bestand. Kopieer het gewijzigde bestand nu naar /etc/apache2/ en bevestig als je wordt gevraagd of je het reeds bestaande bestand wilt vervangen.

Als PHP probeert met MySQL te communiceren, gebruikt het een socket-bestand om contact met MySQL te maken. PHP verwacht dit bestand te vinden in /tmp/mysql.sock terwijl MySQL het bestand in /var/mysql/mysql.sock creëert. Dit is al jaren zo en ik begrijp niet waarom dit niet door de betreffende partijen wordt opgelost.

De “tijdelijke” oplossing is PHP of MySQL te vertellen dat het socket-bestand elders moet worden gecreëerd c.q. gevonden. De makkelijkste manier is de volgende.

1) open TextEdit en type de volgende vier regels:

[mysqld]
socket=/var/mysql/mysql.sock
[client]
socket=/var/mysql/mysql.sock

2) bewaar dit tekstbestand onder: /etc/my.cnf

Het kan zijn dat je dit bestand niet zomaar kunt opslaan in /etc. In dat geval kun je het bestand eerst op de desktop opslaan. Vervolgens type je command-shift-G. Er verschijnt een dialoogvenstertje, waarin je /etc typt. Als je op Go (of Ga) klikt, zie je een Finder-venster met de inhoud van de map /etc verschijnen. Nu kun je het bestand my.cnf naar deze map kopiëren. Eventueel moet je nog een beheerdersnaam en -wachtwoord invullen.

Nu dien je web sharing in de Systeemvoorkeuren uit te schakelen en weer in te schakelen. Ok MySQL kun je middels het geïnstalleerde voorkeurenpaneel uit- en weer inschakelen.

PHP zou nu van MySQL gebruik moeten kunnen maken.

Free Christmas Gift from Apple

Apple has a little tradition of offering iOS customers free music and apps around Christmas. To get the goodies, you’ll need the “12 Days of Christmas” app, which was just released in the App Store today. An additional download comes available every day and every download is available for 24 hours.

The 12 Days of Christmas app sends push notifications. From : “To receive daily notifications, please activate Push Notifications when prompted (or enable them in Settings > Notifications). Some free content cannot be downloaded over the cellular network. If that is the case, please connect using WiFi and try again. If you are still experiencing issues with the iTunes 12 Days app please send an email with as much relevant detail to: 12days@group.apple.com“.

Get it here.