locked
MS Access query Help RRS feed

  • Question

  • User321472486 posted

    Hi to all,

    I am using MS Access Database for my website. The table is following:

    Table Name : images

    Column Names:

    image_id : Primary Key

    person_id: Text (It has duplicate value, because person has many images in this database)

    image_name: Text (This is image name and image stored in folder with this name)

    person_name: Text

    In this database different persons have many images stored with duplicate person_id 

    I want to retrieve single image on bases of person_id with DISTINCT sql  keyword.

    Basically what I wanted to do, on web page i want to show only single image and person's name . Person has many images in this database. If visitor want's to see more images of particular person then visitor has to click on person name and the link will redirect to other page of person's more images.


    To show single image of particular person I am using this sql command but it did not work.

    ("Select DISTINCT person_id, image_name, person_name from images ORDER BY person_id")

    above command shows all the images from database.

    Please help.

    Big thanks

    Harsh Sabharwal




     



     

    Friday, May 21, 2010 2:04 AM

Answers

  • User-1507865547 posted

    Try below query

    Select person_id, MAX(image_name),MAX(person_name) from images

    GROUP BY person_id

    ORDER BY person_id

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 21, 2010 2:38 AM
  • User516094431 posted

    Hi Harsh,

          you have to need you select all image against specific person_id and store in Datatable or DataSet.

    then apply paging but in one page show 1 image.  I think you got my point.

    for select all images use this query.

    select image_id, image_name, person_name from images where person_id = '1' order by  image_id


    person_id pass from coding side.


    Thanks,

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 21, 2010 2:52 AM

All replies

  • User-1507865547 posted

    Try below query

    Select person_id, MAX(image_name),MAX(person_name) from images

    GROUP BY person_id

    ORDER BY person_id

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 21, 2010 2:38 AM
  • User516094431 posted

    Hi Harsh,

          you have to need you select all image against specific person_id and store in Datatable or DataSet.

    then apply paging but in one page show 1 image.  I think you got my point.

    for select all images use this query.

    select image_id, image_name, person_name from images where person_id = '1' order by  image_id


    person_id pass from coding side.


    Thanks,

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 21, 2010 2:52 AM