MySQL - SQL's to answer basic queries?

Hey there. I need some help for some basic SQL's while working with MySQL. I have to write SQL's to answer the following queries:

1. How many buildings are there on parcel 123?

2. What is the total value of the property (parcel + buildings) located at 55 Main Street?

3. What is the name of the owner(s) of parcel 123?

4. What is the total value of the properties (parcels + buildings) owned by John Smith?

5. List the name of all persons who own a building where they do not live.

Any help is beyond appreciated! Thanks.

Update:

EDIT:

NOTE*: These are just flat out questions asked by the teacher. There are no tables, or actual data. I just have to create SQL statements with arbitrary data.

Comments

  • There's no way to give you the SQL queries because you haven't provided us with table or column names. We don't know the structure of your database so the queries can't be created for you.

    In general, you can get all information from a table using:

    SELECT * FROM my_table_name;

    OR using a WHERE clause:

    SELECT * FROM my_table_name

    WHERE my_column_name = "John Smith";

    There are good tutorials here:

    http://sqlzoo.net/

  • Just making guesses at tables and columns for the first couple:

    1) SELECT COUNT(*) FROM buildings WHERE parcel = '123'

    2) SELECT parcelValue + buildingValue FROM

    (SELECT propertyValue AS parcelValue FROM parcels WHERE location = '55 Main Street'),

    (SELECT SUM(propertyValue) AS buildingValue FROM buildings WHERE parcel IN

    (SELECT parcel FROM parcels WHERE location = '55 Main Street')

    GROUP BY location)

Sign In or Register to comment.