SQL embedded in PHP
Embed the following in a PHP program. You can do multiple in one program if you want to - just be
sure it is clear what problem you are solving on the output. Note that the first group using the
donor table. The others can be a table of your choice.
To do this you need the database table donor.
IDNO NAME STADR CITY ST ZIP DATEFST YRGOAL CONTACT
----- --------------- --------------- ---------- -- ----- --------- --------- ------------
11111 Stephen Daniels 123 Elm St Seekonk MA 02345 03-JUL-98 500 John Smith
12121 Jennifer Ames 24 Benefit St Providence RI 02045 24-MAY-97 400 Susan Jones
22222 Carl Hersey 24 Benefit St Providence RI 02045 03-JAN-98 Susan Jones
23456 Susan Ash 21 Main St Fall River MA 02720 04-MAR-92 100 Amy Costa
33333 Nancy Taylor 26 Oak St Fall River MA 02720 04-MAR-92 50 John Adams
34567 Robert Brooks 36 Pine St Fall River MA 02720 04-APR-98 50 Amy Costa
Create a query to display the unique or distinct contacts from the donor table that you just created.
Create a query to sort by yrgoal in descending order.
Create a query to concatenate the street address so you print stadr followed by a comma and a space and then city
followed by a comma and a space and then state followed by a space and then zip.
Create a query to sort by datefst within state.
Create a query to display all contacts that have a Jo in their name.
Create a query to display all names where the first name starts with letters in the J-R range. Use the BETWEEN clause.
Create a query to display all donors that live in Providence, Seekonk or Swansea. Use the IN clause.
Create a query to display all people that gave their first contribution in 92.
Create a query to list all donors who have Susan Jones or John Adams as their contact person and display them in the order
of name within city within state.
Using the table you created for SQL assignment #2, do a query using single row functions that flip the name so that it
displays as first middle (if any) last instead of last/first middle. For example: Doe/John should be flipped so it displays
as John Doe, Smith/Mary S should be flipped so it displays as Mary S Smith, Adams-Costa/Susan A should be flipped so it
displays as Susan A Adams-Costa.
Create a query where one thing has to be true and in addition either of two other things.
Create a query where two things have to be true or two other things have to be true.