sql statement problem

Results 1 to 2 of 2

Thread: sql statement problem

  1. #1
    Join Date
    Dec 1969

    Default sql statement problem

    Hi, I’m trying to re-structure my data to include a category table.<BR><BR>e.g.<BR><BR>A project can be in one or many categories<BR><BR>So I have my projects table (projects), with each project having a unique id (projid).<BR>I also have a projectcat table, which lists each project id and each category<BR><BR>e.g<BR><BR>projects table<BR><BR>projid projtitle<BR>1 hello<BR>2 goodbye<BR>3 yes<BR>4 no<BR>5 yip<BR><BR>Projcat table<BR><BR>Proid category<BR>1 1<BR>1 120<BR>1 204<BR>2 1<BR>2 115<BR><BR>I only want to display each project once in the output, but I’m having probs doing this:<BR><BR>Select * from projects left join projcat on projects.projid = projcat.proid<BR><BR>This gives every occurrence of each combination.<BR><BR>Any ideas?<BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: sql statement problem

    Handle that issue in the presentation (there is a FAQ dealing with this in more detail).<BR><BR>if you retrieve the data ordered by projtitle:<BR><BR>Select * from projects left join projcat <BR>on projects.projid = projcat.proid<BR>order by projtitle<BR><BR><BR>you can keep track of when you get a new project and only then display the project data.

Posting Permissions

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