Results 1 to 5 of 5

Thread: silly question

  1. #1
    Join Date
    Jan 2005
    Location
    swansea, wales
    Posts
    2

    silly question

    hi

    I'm currently designing a searchable artist gallery and have a problem with my SQL querying.

    I have the artworks entered in the database as unique entries and have entered the artists forename and surname in separate columns so that they can be seached for by the first letter of their surname.

    The problem is that when a user searches for an artist the results return as many results as there are artworks, rather than artists, in other words if harry potter has 20 pots he appears 20 times.

    Please can anyone advise me how to ammend my query so that he appears only once!
    Last edited by babel; 01-28-2005 at 07:53 AM.

  2. #2
    Join Date
    Oct 2002
    Posts
    93
    Try using the DISTINCT word in your SQL statement...

    SELECT DISTINCT fieldname FROM tablename

    and you'll only get ONE record per fieldname.

    Take care,
    John

  3. #3
    Join Date
    Oct 2002
    Posts
    93
    Try using the DISTINCT word in your SQL statement...

    SELECT DISTINCT fieldname FROM tablename

    and you'll only get ONE record per fieldname.

    Take care,
    John

  4. #4
    Join Date
    Feb 2003
    Posts
    1,048
    The artworks should be stored in a separate table from the paintings. How will you handle it if you have two distinct artists with the same first and last name?

    You should have an artists table with each artist having a unique integer ID. The artworks table should contain only the artist's unique integer ID.

  5. #5
    Join Date
    Jan 2005
    Location
    swansea, wales
    Posts
    2
    simple but effective!

    thanks!!!

Posting Permissions

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