Results 1 to 7 of 7

Thread: Developing a "Phonebook" With Microsoft Access

  1. #1
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    82
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Developing a "Phonebook" With Microsoft Access

    Please Note: First time user of anything "database".

    I have a school assignment in which I must create a pseudo phonebook with 30 entries, and each entry having to be described by their first and last names, their adresses, their phone numbers, and a variety of other seemingly random details. I have completed the table (along with its various entries) and now I am posed with a problem. I am supposed to "Design a query where you print off individuals who are born in the same month." How would I go about creating something like that? Thanks in advance...

  2. #2
    Join Date
    Jun 2006
    Location
    Acton Ontario Canada.
    Posts
    677
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default

    if its for school asking for a code here is cheating.

    you would have to have a month column in your database table, then select it.
    IE
    mysql_query("SELECT * FROM phonebook WHERE month='febuary'");
    then echo each result.

    http://www.w3schools.com/php/php_mysql_intro.asp

    read that section over. it helps.


    ps. pointing you in the right direction isnt cheating
    - Ryan "Boxxertrumps" Trumpa
    Come back once it validates: HTML, CSS, JS.

  3. #3
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    82
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I don't feel its really cheating since my teacher's don't even have a clue. They just assign it to me and expect me to get it done. Kind of a ripoff...

  4. #4
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by boxxertrumps View Post
    you would have to have a month column in your database table, then select it.
    Not at all. Use the built-in SQL EXTRACT function (any decent database should implement it)

      EXTRACT(field FROM source)

    using a field value of 'month':

      SELECT * FROM phonebook WHERE EXTRACT(MONTH FROM dob) = 2

    Permitted types for source will vary, but date/time types should always be accepted. The documentation for your DBMS will contain more information.

    Mike

  5. #5
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    82
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Do you know how one would access the source in Access? Probably not...
    Anyway, the dates are divided into dd/mm/yyyy format. Will that be a problem with the query?

  6. #6
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Aragoth View Post
    Do you know how one would access the source in Access?
    Open the Query in design view, then open the context menu and select "SQL View" from the top of the menu. You can also use the View menu, and the View toolbar button.

    Anyway, the dates are divided into dd/mm/yyyy format.
    As long as the column is a Date/Time type, the format doesn't matter.

    An amendment to my previous post: in Access, use the DatePart function. The first argument is the portion of the value, and the second is the date value. For example,

      SELECT * FROM phonebook WHERE DatePart('m', dob) = 2

    is the Access equivalent to second SQL statement in my previous post, which would return everyone that was born in February.

    Mike

  7. #7
    Join Date
    Dec 2005
    Location
    Canada
    Posts
    82
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    I have never used any type of database before, so please bear with me. I can understand what you are saying (the query would extract the data from the table entitled Phonebook). Must I match the fields exactly in the example you provided? I attempted to add the script you gave directly into the SQL view, but the result was that the query saved, and allowed me to enter data, but did not access the months of February when 2 was entered. Is there something wrong with the way I placed the code, or do I have to edit it to meet my specific needs?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •